Yohan_Sumathipala:

loss2 = Variable(loss.data)
loss2.backward()


This won’t actually compute any gradients. It detaches loss from the rest of the computation graph; you’re creating a new node that is loss2 = Variable(loss.data) that is not connected to the rest of the computation graph.