Cleanup Trainer and expose customization points
Clean up some parts of the code of `Trainer` and expose some function as customization points (doc will follow if you agree on this).
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=h1) Report
> Merging [#5982](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/2c0da7803a75f0fc6e6d484e23ca283faa32d785&el=desc) will **decrease** coverage by `0.15%`.
> The diff coverage is `60.00%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/5982/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #5982      +/-   ##
==========================================
- Coverage   78.66%   78.51%   -0.16%     
==========================================
  Files         146      146              
  Lines       26227    26240      +13     
==========================================
- Hits        20632    20602      -30     
- Misses       5595     5638      +43     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/trainer.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90cmFpbmVyLnB5) | `40.87% <60.00%> (+2.41%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_electra.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9lbGVjdHJhLnB5) | `26.02% <0.00%> (-69.52%)` | :arrow_down: |
| [src/transformers/generation\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9nZW5lcmF0aW9uX3RmX3V0aWxzLnB5) | `86.46% <0.00%> (-0.26%)` | :arrow_down: |
| [src/transformers/file\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9maWxlX3V0aWxzLnB5) | `81.49% <0.00%> (+0.29%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/5982/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9kaXN0aWxiZXJ0LnB5) | `98.79% <0.00%> (+33.89%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=footer). Last update [2c0da78...e583bf0](https://codecov.io/gh/huggingface/transformers/pull/5982?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
