First case, I’m not sure. I save the loss.item() in another variable before loss.backward()
Second case, when you are training, each loss.backward() changes the model weights so the next batch loss would be different from what you would expect while doing model.eval()
Hope that answers your question, would be happy to elaborate if not.