Solved by albanD in post #2 
              
              
                Hi .requires_grad_() should be used only to make the tensor require gradients. In this case you don’t want to require gradients so you should remove it. 
Otherwise this is the right usage for torch.no_grad().