Thanks for your reply. I know *_ operations are in place, but what bothers me is that why this in place operation leads to this strange error, since this operation happens in the forward pass and loss.backward() happens in the backward pass.