Solved by albanD in post #4 
              
              
                If you use .backward(), then you can simply do that by setting the .grad field of your parameters before calling the .backward() function. No need to change anything else.