Just add retain_variables=True to the first backward() call when you intend to perform backpropagation multiple times through the same variables.
y.backward(retain_variables=True)   #calculates gradients