Solved by gphilip in post #5 
              
              
                In the first example x is a leaf tensor, since it is a tensor that you directly created. By default, gradients are computed only with respect to leaf tensors, so x.grad has actual numbers in it. 
In the second example x is not a leaf tensor, since it is not a tensor that you directly created: it is …