in dict_minimize/torch_api.py [0:0]
def _from_np(X, dtype):
assert X.dtype.kind == "f"
dtype_ = X.dtype
X = np.asarray(X) # In case a scalar was given
assert X.dtype == dtype_
Xt = torch.from_numpy(X).type(dtype)
# Do this weird way to avoid `UserWarning` from torch.
Xt = Xt.clone().detach().requires_grad_(True)
return Xt