Your problem is this
x = torch.tensor([1., 2], requires_grad=True)
y = torch.tensor(x, requires_grad=True)
y.sum().backward()

Now when you backprop through y, y is a leaf (because torch.tensor creates leaf), there is no path to propagate the gradients to x i.e. why x.grad=None.