Solved by KFrank in post #8 
              
              
                Hi Rishi! 

The problem is that you have to rebuild the “computation graph” 
before you call .backward() for a second time.  Both indexing 
into a and setting that “value” to param count as part of the 
computation graph. 
Consider: 
>>> import torch
>>> print (torch.__version__)
1.9.0
>>>
>>> param…