If no other names point to the original tensor named a, then the original tensor will be lost to the garbage collector. On the other hand if a was a Variable, then the original variable a is stored in the computation graph for the new Variable named a. When you operate on Variables, PyTorch automatically stores everything it needs for backpropagation.


Your code is fine. PyTorch will store all of the intermediate values that it needs.