Solved by ptrblck in post #8 
              
              
                As long as you are using PyTorch operations Autograd would be able to create the computation graph and calculate the gradients of the loss w.r.t. to all parameters in this graph. 
You can verify it by checking the .grad attributes of all encoder parameters before the first backward call (should be N…