Try to fix training Loss inconsistent after resume from old checkpoint (#25872)
* fix loss inconsistent after resume #25340
* fix typo
* clean code
* reformatted code
* adjust code according to comments
* adjust check_dataloader_randomsampler location
* return sampler only
* handle sampler is None
* Update src/transformers/trainer_pt_utils.py
thanks @amyeroberts
Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
---------
Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>