Make sure to zero the gradients (if x.grad: x.grad.zero_()) before calculating new y.
if x.grad: x.grad.zero_()
y
Some more info: