Fall back to `observed_batch_size` when the `dataloader` does not know the `batch_size`.
# What does this PR do?

Motivated by #12995, this adds support for users to provide a `batch_sampler` to the DataLoader instead of a (single index) `sampler`. (The [pytorch docs](https://pytorch.org/docs/stable/data.html) has more info on these two sampler types.)

When we provide a `batch_sampler`, a DataLoader doesn't know the batch size, so it's set to `None`. Currently, the Trainer retrieves the batch size from the data loader:

https://github.com/huggingface/transformers/blob/1fec32adc6a4840123d5ec5ff5cf419c02342b5a/src/transformers/trainer.py#L2172

... leading to a crash a few lines later when it tries to use it:

https://github.com/huggingface/transformers/blob/1fec32adc6a4840123d5ec5ff5cf419c02342b5a/src/transformers/trainer.py#L2217

```txt
TypeError: repeat(): argument 'repeats' (position 1) must be tuple of ints, not NoneType
```

Fortunately, the observed batch size is calculated between those two spots, so this change simply uses it instead if the batch size wasn't found on the data loader.

I added the `None` check just to ensure this does not change existing behavior, though I would imagine it would not even without the check.

_Re: testing: I was not sure how much code you want surrounding this fix / added support, as I don't think Transformers includes any batch samplers itself yet, so I didn't include a test. Let me know otherwise and I can take a stab at it!_

## Who can review?

I suggest @sgugger due to issue context and Trainer :-)

Apologies for the ping @sgugger, but might you be able to take a look at this? tl;dr with this 2-line change, users can now provide batch samplers without evaluation crashing 🥳 <|||||>Thanks, Sylvain! Gaah, sorry, your inbox must have been crazy by the time you came back 😅  — I hope you had a nice break!

<|||||>It was great, thanks for asking!