Support for version spec in requires & arbitrary mismatching depths across folders
Author: LysandreJik
Pull request: yes

This PR adds two features:

### Version specification in `@requires`


Specific versions can now be specified in each backend. For example, this is how you would specify
a requirement on torch>=2.6, as well as `accelerate`, on the `Trainer` class:

```python
from .utils.import_utils import requires

@requires(backends=("torch>=2.6", "accelerate"))
class Trainer:
    ...
```

The following operators can be used to specify versions: `==`, `>`, `>=`, `<`, `<=`, `!=`.

### Arbitrary depth of model definition

This completes the `spread_import_structure` method so that arbitrary depths of import structures may be created correctly. 

For example, the following (simplified and exemplified) import structure has four different levels of depth:

```py
{
    frozenset(): {"dummy_non_model": {"DummyObject"}},
    "models": {
        frozenset(): {"dummy_config": {"DummyConfig"}},
        "albert": {
            frozenset(): {"configuration_albert": {"AlbertConfig", "AlbertOnnxConfig"}},
            frozenset({"torch"}): {
                "modeling_albert": {
                    "AlbertForMaskedLM",
                }
            },
        },
        "llama": {
            frozenset(): {"configuration_llama": {"LlamaConfig"}},
            frozenset({"torch"}): {
                "modeling_llama": {
                    "LlamaForCausalLM",
                }
            },
        },
        "deprecated": {
            "transfo_xl": {
                frozenset({"torch"}): {
                    "modeling_transfo_xl": {
                        "TransfoXLModel",
                    }
                },
                frozenset(): {
                    "configuration_transfo_xl": {"TransfoXLConfig"},
                    "tokenization_transfo_xl": {"TransfoXLCorpus", "TransfoXLTokenizer"},
                },
            },
            "deta": {
                frozenset({"torch"}): {
                    "modeling_deta": {"DetaForObjectDetection", "DetaModel", "DetaPreTrainedModel"}
                },
                frozenset(): {"configuration_deta": {"DetaConfig"}},
                frozenset({"vision"}): {"image_processing_deta": {"DetaImageProcessor"}},
            },
        },
    }
}
```

The first frozenset is encountered at `frozenset()`, the second at `models.frozenset()`, the third at `models.albert.frozenset()`, and the fourth at `models.deprecated.transfo_xl.frozenset()`.

This change ensures that this gets correctly compiled to a dict with all frozensets propagated at the top:

```py
{
    frozenset(): {
        "dummy_non_model": {"DummyObject"},
        "models.dummy_config": {"DummyConfig"},
        "models.albert.configuration_albert": {"AlbertConfig", "AlbertOnnxConfig"},
        "models.llama.configuration_llama": {"LlamaConfig"},
        "models.deprecated.transfo_xl.configuration_transfo_xl": {"TransfoXLConfig"},
        "models.deprecated.transfo_xl.tokenization_transfo_xl": {"TransfoXLCorpus", "TransfoXLTokenizer"},
        "models.deprecated.deta.configuration_deta": {"DetaConfig"},
    },
    frozenset({"torch"}): {
        "models.albert.modeling_albert": {"AlbertForMaskedLM"},
        "models.llama.modeling_llama": {"LlamaForCausalLM"},
        "models.deprecated.transfo_xl.modeling_transfo_xl": {"TransfoXLModel"},
        "models.deprecated.deta.modeling_deta": {"DetaForObjectDetection", "DetaModel", "DetaPreTrainedModel"},
    },
    frozenset({"vision"}): {"models.deprecated.deta.image_processing_deta": {"DetaImageProcessor"}},
}
```


Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page). This will assign reviewers and trigger CI.

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_37854). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.