[Trainer] Very different loss reported during training vs. at the end.
I have trained GPT from scratch. During training, I got logs outputting evaluation and 'loss', like shown below:

`{'loss': 6.5349, 'learning_rate': 0.00014698625308424393, 'epoch': 42.65}`

But after the last step I get this log, different to the previous ones:

`{'train_runtime': 751.251, 'train_samples_per_second': 580108.554, 'train_steps_per_second': 566.455, 'train_loss': 0.008420203693772214, 'epoch': 50.0}`

Besides, I get this metrics:

```
 ***** train metrics *****
epoch                    =       50.0
train_loss               =     0.0084
train_runtime            = 0:12:31.27
train_samples            =    8716143
train_samples_per_second = 580087.323
train_steps_per_second   =    566.434
```

The values of `train_loss` and `loss` are remarkably different, so what's each of them referring to? And what is the real training loss? If it's the last one, what is the point of plotting the training curves using the variable `loss`?


cc @sgugger <|||||>It looks like the reported `"train_loss"` is averaged twice, so it's not accurate. Will fix this week.<|||||>I was actually wrong, and the training loss is properly computed (see #15096 that adds a test which is passing). Are you sure you are using the most recent version of Transformers?<|||||>I trained this model using transformers==4.14.1. Was it fixed after that?  If so, would I need to train again?
Training takes several weeks so updating to every new version is not possible in my case.<|||||>I think the value of 'train_loss' is meant to be different to 'loss'. If you follow the code: https://github.com/huggingface/transformers/blob/master/src/transformers/trainer.py

logs["loss"] = round(tr_loss_scalar / (self.state.global_step - self._globalstep_last_logged), 4)
'loss': loss on the batch data within one step only

train_loss = self._total_loss_scalar / self.state.global_step
'train_loss' average on all steps


<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.