Solved by yf225 in post #2 
              
              
                In the Python frontend, using torch.tensor() to copy-construct a Tensor from a Tensor is actually deprecated, and the recommended way is sourceTensor.clone().detach().requires_grad_(). 
In C++ frontend, currently the best way to achieve the same functionality is: 
#include <torch/csrc/autograd/varia…