Check for mapping/dict in distributed_concat function
Author: prajwal967
Pull request: yes

# What does this PR do?
* Feature request for checking if input to the distributed_concat function is of type Mapping/Dict.
* The [distributed_concat](https://github.com/huggingface/transformers/blob/b9af152efb748b1bff8f6fe0130e62ebb8e11a53/src/transformers/trainer_pt_utils.py#L188) function currently checks for the List/Tuple type, but does not check for the Mapping/Dict type.
* The [nested_xla_mesh_reduce](https://github.com/huggingface/transformers/blob/b9af152efb748b1bff8f6fe0130e62ebb8e11a53/src/transformers/trainer_pt_utils.py#L171) & [smp_gather](https://github.com/huggingface/transformers/blob/b9af152efb748b1bff8f6fe0130e62ebb8e11a53/src/transformers/trainer_pt_utils.py#L1084) functions have an IF statement to check if the input is of type Mapping/Dict and then iterates over the items.

Fixes # (issue): https://github.com/huggingface/transformers/issues/21497


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section? **Yes**
- [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. **Yes**. Link: https://github.com/huggingface/transformers/issues/21497
- [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).
- [ ] Did you write any new necessary tests? **No**


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@sgugger, @stas00

Comments:
_The documentation is not available anymore as the PR was closed or merged._

Sylvain, wrt failing test - it looks like `src/accelerate/utils/memory.py` is the new location of `find_executable_batch_size` - backcompat breakage in accelerate? need to require `accelerate>=0.16.0` in `setup.py` here?

```

tests/trainer/test_trainer_utils.py:432: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

function = <function TrainerUtilsTest.test_executable_batch_size.<locals>.mock_training_loop_function at 0x7fe748946290>
starting_batch_size = 64, auto_find_batch_size = True

    def find_executable_batch_size(
        function: callable = None, starting_batch_size: int = 128, auto_find_batch_size: bool = False
    ):
        """
        Args:
        A basic decorator that will try to execute `function`. If it fails from exceptions related to out-of-memory or
        CUDNN, the batch size is cut in half and passed to `function` `function` must take in a `batch_size` parameter as
        its first argument.
            function (`callable`, *optional*)
                A function to wrap
            starting_batch_size (`int`, *optional*)
                The batch size to try and fit into memory
            auto_find_batch_size (`bool`, *optional*)
                If False, will just execute `function`
        """
        if function is None:
            return functools.partial(
                find_executable_batch_size,
                starting_batch_size=starting_batch_size,
                auto_find_batch_size=auto_find_batch_size,
            )
    
        if auto_find_batch_size:
            requires_backends(find_executable_batch_size, "accelerate")
            import accelerate.memory_utils as mem_utils
    
>           return mem_utils.find_executable_batch_size(function=function, starting_batch_size=starting_batch_size)
E           AttributeError: module 'accelerate.memory_utils' has no attribute 'find_executable_batch_size'

src/transformers/trainer_utils.py:651: AttributeError
```

This is fixed in #21501