You are breaking the computation graph by recreating the loss tensor here:
loss = Variable(loss, requires_grad=True)

Remove this line of code and also remove the usage of Variable, as it’s deprecated since PyTorch 0.4