Solved by lewtun in post #2 
              
              
                Hey @MahdiA what you have looks pretty close - I think you just need loss.backward() instead of loss.backwards() 
Does that solve your issue?