Add check to ensure all tensors are defined before they are used and that jld2 file contains all and only required tensors with expected dimensions.