Loss from calling model and computing explicitly don't match

Hi All,

  I'm calling the model like the following
output = model(input, labels=target_ids)
loss1 = output.loss

loss2 = F.cross_entropy(outputs.logits, target_ids)

I expect both the losses to be same but they aren’t. What am I missing?
The model is of class GPT2LMHeadModel