Solved by albanD in post #2 
              
              
                Hi, 
I think the problem is that you forgot that indexing is a proper operation. And so X[i] returns a different Tensor than X, and X[i] was not used to compute the norm, hence the error. 
If you give X as input, you should get the gradients for all X and then be able to access X.grad[i].