Avoid accessing .dataset of a DataLoader in Trainer
# What does this PR do?

* Respects get_train_dataloader and such, rather than going back and looking at .train_dataset or requiring attributes in the dataloader to be accessible directly.
   * This allows for overriding it by any object which implements the methods required by a DataLoader (`__len__` and `__iter__`) without additional requirements.
   * The original motivation was to train on a multi-task dataloader which defers to multiple dataloaders. 


## Before submitting
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case. 
     - Discussed in #16388
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


_The documentation is not available anymore as the PR was closed or merged._<|||||>@[sgugger](https://github.com/sgugger) this should be ready for review.
You were right that there were a couple of more places to change, and the logic is quite inconsistent in places. I've tried to be on the defensive side in covering cases:

* dataloader.dataset can exist or not, and have a length or not
* dataloader always has a len, but it can raise an exception in fairly common cases

This implementation works for my particular case, giving the same output in training+evaluation as before, but without the really painful workarounds.

I had a look at tests and they look complicated, so I will add some after getting confirmation that this is ok otherwise.

<|||||>Thanks for implementing all the tweaks!