[trainer] 2 bug fixes and a rename
Fixes a bug in https://github.com/huggingface/transformers/pull/12257 and https://github.com/huggingface/transformers/pull/12276 and renames the function in the latter and adds a docstring.

Also added an extended DDP test to tests `log_level_replica`.

Fixes: https://github.com/huggingface/transformers/issues/12310

@sgugger 
