Repository: huggingface/transformers
Pull request: Fix error on importing unavailable torch.distributed

# What does this PR do?
Currently PyTorch on Windows builds don't support distributed module and when users attempt to use transformers or a lib dependent on it, it fails with the following error:
```
File "C:\Users\Micha\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\distributed\tensor\__init__.py", line 4, in <module>
    import torch.distributed.tensor._ops  # force import all built-in dtensor ops
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\distributed\tensor\_ops\__init__.py", line 2, in <module>
    from ._conv_ops import *  # noqa: F403
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\distributed\tensor\_ops\_conv_ops.py", line 5, in <module>
    from torch.distributed.tensor._dtensor_spec import DTensorSpec, TensorMeta
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\distributed\tensor\_dtensor_spec.py", line 6, in <module>
    from torch.distributed.tensor.placement_types import (
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\distributed\tensor\placement_types.py", line 8, in <module>
    import torch.distributed._functional_collectives as funcol
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\distributed\_functional_collectives.py", line 9, in <module>
    import torch.distributed.distributed_c10d as c10d
  File "C:\Users\Micha\AppData\Local\Programs\Python\Python312\Lib\site-packages\torch\distributed\distributed_c10d.py", line 23, in <module>
    from torch._C._distributed_c10d import (
ModuleNotFoundError: No module named 'torch._C._distributed_c10d'; 'torch._C' is not a package
```
This is caused by `model_debugging_utils.py` having an unguarded `import torch.distributed.tensor`. This PR ensures that the distributed module is available before including its tensor module.

## 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#create-a-pull-request),
      Pull Request section?
- [ ] 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.
- [ ] 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?


## Who can review?
 @ArthurZucker

Changed files:
filename: src/transformers/model_debugging_utils.py
patch: @@ -26,11 +26,13 @@
 
 if is_torch_available():
     import torch
-    import torch.distributed.tensor
     from safetensors.torch import save_file
 
     # Note to code inspectors: this toolbox is intended for people who add models to `transformers`.
-    _torch_distributed_available = torch.distributed.is_available()
+    if torch.distributed.is_available():
+        import torch.distributed.tensor
+
+        _torch_distributed_available = True
 else:
     _torch_distributed_available = False
 from .utils import logging