Solved by albanD in post #2 
              
              
                Hi, 
You can do this, and if the backward does not raise an error you will get the correct gradients. 
What can happen though is that you get Tensor needed for backward has been changed by an inplace operation. As inplace operations can change a tensor needed during the backward pass. The engine is …