diff --git a/src/transformers/models/granite/__init__.py b/src/transformers/models/granite/__init__.py index 5a98daa072d5..90c1e7abe7a0 100644 --- a/src/transformers/models/granite/__init__.py +++ b/src/transformers/models/granite/__init__.py @@ -13,45 +13,15 @@ # limitations under the License. from typing import TYPE_CHECKING -from ...utils import ( - OptionalDependencyNotAvailable, - _LazyModule, - is_torch_available, -) +from ...utils import _LazyModule +from ...utils.import_utils import define_import_structure -_import_structure = { - "configuration_granite": ["GraniteConfig"], -} - -try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_granite"] = [ - "GraniteForCausalLM", - "GraniteModel", - "GranitePreTrainedModel", - ] - if TYPE_CHECKING: - from .configuration_granite import GraniteConfig - - try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_granite import ( - GraniteForCausalLM, - GraniteModel, - GranitePreTrainedModel, - ) - + from .modeling_granite import * + from .configuration_granite import * else: import sys - sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) + _file = globals()["__file__"] + sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) diff --git a/src/transformers/models/granite/configuration_granite.py b/src/transformers/models/granite/configuration_granite.py index ed6191adf65b..a8ce323b4e41 100644 --- a/src/transformers/models/granite/configuration_granite.py +++ b/src/transformers/models/granite/configuration_granite.py @@ -177,3 +177,6 @@ def __init__( ) rope_config_validation(self) + + +__all__ = ['GraniteConfig'] \ No newline at end of file diff --git a/src/transformers/models/granite/modeling_granite.py b/src/transformers/models/granite/modeling_granite.py index 7e758947b6dd..6665e0a1f9ba 100644 --- a/src/transformers/models/granite/modeling_granite.py +++ b/src/transformers/models/granite/modeling_granite.py @@ -882,3 +882,6 @@ def forward( hidden_states=outputs.hidden_states, attentions=outputs.attentions, ) + + +__all__ = ['GraniteForCausalLM', 'GraniteModel', 'GranitePreTrainedModel'] \ No newline at end of file diff --git a/src/transformers/models/instructblipvideo/__init__.py b/src/transformers/models/instructblipvideo/__init__.py index 18d20d040150..b96f0db4221c 100644 --- a/src/transformers/models/instructblipvideo/__init__.py +++ b/src/transformers/models/instructblipvideo/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2024 The HuggingFace Team. All rights reserved. +# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,71 +13,17 @@ # limitations under the License. from typing import TYPE_CHECKING -from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available +from ...utils import _LazyModule +from ...utils.import_utils import define_import_structure -_import_structure = { - "configuration_instructblipvideo": [ - "InstructBlipVideoConfig", - "InstructBlipVideoQFormerConfig", - "InstructBlipVideoVisionConfig", - ], - "processing_instructblipvideo": ["InstructBlipVideoProcessor"], -} - - -try: - if not is_vision_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["image_processing_instructblipvideo"] = ["InstructBlipVideoImageProcessor"] - - -try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_instructblipvideo"] = [ - "InstructBlipVideoQFormerModel", - "InstructBlipVideoPreTrainedModel", - "InstructBlipVideoForConditionalGeneration", - "InstructBlipVideoVisionModel", - ] - if TYPE_CHECKING: - from .configuration_instructblipvideo import ( - InstructBlipVideoConfig, - InstructBlipVideoQFormerConfig, - InstructBlipVideoVisionConfig, - ) - from .processing_instructblipvideo import InstructBlipVideoProcessor - - try: - if not is_vision_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .image_processing_instructblipvideo import InstructBlipVideoImageProcessor - - try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_instructblipvideo import ( - InstructBlipVideoForConditionalGeneration, - InstructBlipVideoPreTrainedModel, - InstructBlipVideoQFormerModel, - InstructBlipVideoVisionModel, - ) - + from .modeling_instructblipvideo import * + from .processing_instructblipvideo import * + from .configuration_instructblipvideo import * + from .image_processing_instructblipvideo import * else: import sys - sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) + _file = globals()["__file__"] + sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) diff --git a/src/transformers/models/instructblipvideo/configuration_instructblipvideo.py b/src/transformers/models/instructblipvideo/configuration_instructblipvideo.py index 14687a96e54f..fe456c4f44c3 100644 --- a/src/transformers/models/instructblipvideo/configuration_instructblipvideo.py +++ b/src/transformers/models/instructblipvideo/configuration_instructblipvideo.py @@ -340,3 +340,6 @@ def from_vision_qformer_text_configs( text_config=text_config.to_dict(), **kwargs, ) + + +__all__ = ['InstructBlipVideoConfig', 'InstructBlipVideoQFormerConfig', 'InstructBlipVideoVisionConfig'] \ No newline at end of file diff --git a/src/transformers/models/instructblipvideo/image_processing_instructblipvideo.py b/src/transformers/models/instructblipvideo/image_processing_instructblipvideo.py index b83df54785fa..debef379ebe8 100644 --- a/src/transformers/models/instructblipvideo/image_processing_instructblipvideo.py +++ b/src/transformers/models/instructblipvideo/image_processing_instructblipvideo.py @@ -346,3 +346,6 @@ def _preprocess_image( image = to_channel_dimension_format(image, data_format, input_channel_dim=input_data_format) return image + + +__all__ = ['InstructBlipVideoImageProcessor'] \ No newline at end of file diff --git a/src/transformers/models/instructblipvideo/modeling_instructblipvideo.py b/src/transformers/models/instructblipvideo/modeling_instructblipvideo.py index e91b05bc0152..f743a9a78880 100644 --- a/src/transformers/models/instructblipvideo/modeling_instructblipvideo.py +++ b/src/transformers/models/instructblipvideo/modeling_instructblipvideo.py @@ -1668,3 +1668,6 @@ def generate( outputs = self.language_model.generate(**inputs, **generate_kwargs) return outputs + + +__all__ = ['InstructBlipVideoQFormerModel', 'InstructBlipVideoPreTrainedModel', 'InstructBlipVideoForConditionalGeneration', 'InstructBlipVideoVisionModel'] \ No newline at end of file diff --git a/src/transformers/models/instructblipvideo/processing_instructblipvideo.py b/src/transformers/models/instructblipvideo/processing_instructblipvideo.py index 1d4e59e26b46..715984b9c83d 100644 --- a/src/transformers/models/instructblipvideo/processing_instructblipvideo.py +++ b/src/transformers/models/instructblipvideo/processing_instructblipvideo.py @@ -234,3 +234,6 @@ def from_pretrained(cls, pretrained_model_name_or_path, **kwargs): qformer_tokenizer = AutoTokenizer.from_pretrained(pretrained_model_name_or_path, subfolder="qformer_tokenizer") processor.qformer_tokenizer = qformer_tokenizer return processor + + +__all__ = ['InstructBlipVideoProcessor'] \ No newline at end of file diff --git a/src/transformers/models/mistral/__init__.py b/src/transformers/models/mistral/__init__.py index 31441efe6527..e9ac4303b9da 100644 --- a/src/transformers/models/mistral/__init__.py +++ b/src/transformers/models/mistral/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2023 Mistral AI and The HuggingFace Inc. team. All rights reserved. +# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,106 +13,17 @@ # limitations under the License. from typing import TYPE_CHECKING -from ...utils import ( - OptionalDependencyNotAvailable, - _LazyModule, - is_flax_available, - is_tf_available, - is_torch_available, -) - - -_import_structure = { - "configuration_mistral": ["MistralConfig"], -} - - -try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_mistral"] = [ - "MistralForCausalLM", - "MistralForQuestionAnswering", - "MistralModel", - "MistralPreTrainedModel", - "MistralForSequenceClassification", - "MistralForTokenClassification", - ] - -try: - if not is_flax_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_flax_mistral"] = [ - "FlaxMistralForCausalLM", - "FlaxMistralModel", - "FlaxMistralPreTrainedModel", - ] - -try: - if not is_tf_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_tf_mistral"] = [ - "TFMistralModel", - "TFMistralForCausalLM", - "TFMistralForSequenceClassification", - "TFMistralPreTrainedModel", - ] +from ...utils import _LazyModule +from ...utils.import_utils import define_import_structure if TYPE_CHECKING: - from .configuration_mistral import MistralConfig - - try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_mistral import ( - MistralForCausalLM, - MistralForQuestionAnswering, - MistralForSequenceClassification, - MistralForTokenClassification, - MistralModel, - MistralPreTrainedModel, - ) - - try: - if not is_flax_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_flax_mistral import ( - FlaxMistralForCausalLM, - FlaxMistralModel, - FlaxMistralPreTrainedModel, - ) - - try: - if not is_tf_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_tf_mistral import ( - TFMistralForCausalLM, - TFMistralForSequenceClassification, - TFMistralModel, - TFMistralPreTrainedModel, - ) - - + from .modeling_tf_mistral import * + from .modeling_flax_mistral import * + from .configuration_mistral import * + from .modeling_mistral import * else: import sys - sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) + _file = globals()["__file__"] + sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) diff --git a/src/transformers/models/mistral/configuration_mistral.py b/src/transformers/models/mistral/configuration_mistral.py index c4b874f27017..3912fb9a34cc 100644 --- a/src/transformers/models/mistral/configuration_mistral.py +++ b/src/transformers/models/mistral/configuration_mistral.py @@ -159,3 +159,6 @@ def __init__( tie_word_embeddings=tie_word_embeddings, **kwargs, ) + + +__all__ = ['MistralConfig'] \ No newline at end of file diff --git a/src/transformers/models/mistral/modeling_flax_mistral.py b/src/transformers/models/mistral/modeling_flax_mistral.py index 3bff2a628122..63c9d0384e37 100644 --- a/src/transformers/models/mistral/modeling_flax_mistral.py +++ b/src/transformers/models/mistral/modeling_flax_mistral.py @@ -740,3 +740,6 @@ def update_inputs_for_generation(self, model_outputs, model_kwargs): _CONFIG_FOR_DOC, real_checkpoint=_REAL_CHECKPOINT_FOR_DOC, ) + + +__all__ = ['FlaxMistralForCausalLM', 'FlaxMistralModel', 'FlaxMistralPreTrainedModel'] \ No newline at end of file diff --git a/src/transformers/models/mistral/modeling_mistral.py b/src/transformers/models/mistral/modeling_mistral.py index 90c38895b428..d17e6a5b80ca 100644 --- a/src/transformers/models/mistral/modeling_mistral.py +++ b/src/transformers/models/mistral/modeling_mistral.py @@ -1146,3 +1146,6 @@ def forward( hidden_states=outputs.hidden_states, attentions=outputs.attentions, ) + + +__all__ = ['MistralForCausalLM', 'MistralForQuestionAnswering', 'MistralModel', 'MistralPreTrainedModel', 'MistralForSequenceClassification', 'MistralForTokenClassification'] \ No newline at end of file diff --git a/src/transformers/models/mistral/modeling_tf_mistral.py b/src/transformers/models/mistral/modeling_tf_mistral.py index 5c21dd3c3f53..4ab1ecdab9a6 100644 --- a/src/transformers/models/mistral/modeling_tf_mistral.py +++ b/src/transformers/models/mistral/modeling_tf_mistral.py @@ -1052,3 +1052,6 @@ def build(self, input_shape=None): if getattr(self, "score", None) is not None: with tf.name_scope(self.score.name): self.score.build((self.config.hidden_size,)) + + +__all__ = ['TFMistralModel', 'TFMistralForCausalLM', 'TFMistralForSequenceClassification', 'TFMistralPreTrainedModel'] \ No newline at end of file diff --git a/src/transformers/models/mixtral/__init__.py b/src/transformers/models/mixtral/__init__.py index 4ee4834dd249..1723798ddc0b 100644 --- a/src/transformers/models/mixtral/__init__.py +++ b/src/transformers/models/mixtral/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2023 Mixtral AI and The HuggingFace Inc. team. All rights reserved. +# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,54 +13,15 @@ # limitations under the License. from typing import TYPE_CHECKING -from ...utils import ( - OptionalDependencyNotAvailable, - _LazyModule, - is_torch_available, -) - - -_import_structure = { - "configuration_mixtral": ["MixtralConfig"], -} - - -try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_mixtral"] = [ - "MixtralForCausalLM", - "MixtralForQuestionAnswering", - "MixtralModel", - "MixtralPreTrainedModel", - "MixtralForSequenceClassification", - "MixtralForTokenClassification", - ] +from ...utils import _LazyModule +from ...utils.import_utils import define_import_structure if TYPE_CHECKING: - from .configuration_mixtral import MixtralConfig - - try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_mixtral import ( - MixtralForCausalLM, - MixtralForQuestionAnswering, - MixtralForSequenceClassification, - MixtralForTokenClassification, - MixtralModel, - MixtralPreTrainedModel, - ) - - + from .modeling_mixtral import * + from .configuration_mixtral import * else: import sys - sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) + _file = globals()["__file__"] + sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) diff --git a/src/transformers/models/mixtral/configuration_mixtral.py b/src/transformers/models/mixtral/configuration_mixtral.py index 686c214ef25c..fecfb141bc53 100644 --- a/src/transformers/models/mixtral/configuration_mixtral.py +++ b/src/transformers/models/mixtral/configuration_mixtral.py @@ -171,3 +171,6 @@ def __init__( tie_word_embeddings=tie_word_embeddings, **kwargs, ) + + +__all__ = ['MixtralConfig'] \ No newline at end of file diff --git a/src/transformers/models/mixtral/modeling_mixtral.py b/src/transformers/models/mixtral/modeling_mixtral.py index 84ed327d9be9..f06e470a803b 100644 --- a/src/transformers/models/mixtral/modeling_mixtral.py +++ b/src/transformers/models/mixtral/modeling_mixtral.py @@ -1387,3 +1387,6 @@ def forward( hidden_states=outputs.hidden_states, attentions=outputs.attentions, ) + + +__all__ = ['MixtralForCausalLM', 'MixtralForQuestionAnswering', 'MixtralModel', 'MixtralPreTrainedModel', 'MixtralForSequenceClassification', 'MixtralForTokenClassification'] \ No newline at end of file diff --git a/src/transformers/models/musicgen_melody/__init__.py b/src/transformers/models/musicgen_melody/__init__.py index 20c8507aaed7..232ec4432703 100644 --- a/src/transformers/models/musicgen_melody/__init__.py +++ b/src/transformers/models/musicgen_melody/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2024 The HuggingFace Team. All rights reserved. +# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,74 +13,15 @@ # limitations under the License. from typing import TYPE_CHECKING -from ...utils import ( - OptionalDependencyNotAvailable, - _LazyModule, - is_torch_available, - is_torchaudio_available, -) - - -_import_structure = { - "configuration_musicgen_melody": [ - "MusicgenMelodyConfig", - "MusicgenMelodyDecoderConfig", - ], -} - -try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_musicgen_melody"] = [ - "MusicgenMelodyForConditionalGeneration", - "MusicgenMelodyForCausalLM", - "MusicgenMelodyModel", - "MusicgenMelodyPreTrainedModel", - ] - -try: - if not is_torchaudio_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["feature_extraction_musicgen_melody"] = ["MusicgenMelodyFeatureExtractor"] - _import_structure["processing_musicgen_melody"] = ["MusicgenMelodyProcessor"] +from ...utils import _LazyModule +from ...utils.import_utils import define_import_structure if TYPE_CHECKING: - from .configuration_musicgen_melody import ( - MusicgenMelodyConfig, - MusicgenMelodyDecoderConfig, - ) - - try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_musicgen_melody import ( - MusicgenMelodyForCausalLM, - MusicgenMelodyForConditionalGeneration, - MusicgenMelodyModel, - MusicgenMelodyPreTrainedModel, - ) - - try: - if not is_torchaudio_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .feature_extraction_musicgen_melody import MusicgenMelodyFeatureExtractor - from .processing_musicgen_melody import MusicgenMelodyProcessor - - + from .configuration_musicgen_melody import * + from .modeling_musicgen_melody import * else: import sys - sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) + _file = globals()["__file__"] + sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) diff --git a/src/transformers/models/musicgen_melody/configuration_musicgen_melody.py b/src/transformers/models/musicgen_melody/configuration_musicgen_melody.py index e65ad50021c3..04308144bb64 100644 --- a/src/transformers/models/musicgen_melody/configuration_musicgen_melody.py +++ b/src/transformers/models/musicgen_melody/configuration_musicgen_melody.py @@ -256,3 +256,6 @@ def from_sub_models_config( # This is a property because you might want to change the codec model on the fly def sampling_rate(self): return self.audio_encoder.sampling_rate + + +__all__ = ['MusicgenMelodyConfig', 'MusicgenMelodyDecoderConfig'] \ No newline at end of file diff --git a/src/transformers/models/musicgen_melody/modeling_musicgen_melody.py b/src/transformers/models/musicgen_melody/modeling_musicgen_melody.py index dc0e9b882b20..b97aad63b2a3 100644 --- a/src/transformers/models/musicgen_melody/modeling_musicgen_melody.py +++ b/src/transformers/models/musicgen_melody/modeling_musicgen_melody.py @@ -2586,3 +2586,6 @@ def _update_model_kwargs_for_generation( ) return model_kwargs + + +__all__ = ['MusicgenMelodyForConditionalGeneration', 'MusicgenMelodyForCausalLM', 'MusicgenMelodyModel', 'MusicgenMelodyPreTrainedModel'] \ No newline at end of file diff --git a/src/transformers/models/olmo/__init__.py b/src/transformers/models/olmo/__init__.py index b94350cd3310..0dcddac01bec 100644 --- a/src/transformers/models/olmo/__init__.py +++ b/src/transformers/models/olmo/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2024 EleutherAI and The HuggingFace Inc. team. All rights reserved. +# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,47 +13,15 @@ # limitations under the License. from typing import TYPE_CHECKING -from ...utils import ( - OptionalDependencyNotAvailable, - _LazyModule, - is_sentencepiece_available, - is_tokenizers_available, - is_torch_available, -) +from ...utils import _LazyModule +from ...utils.import_utils import define_import_structure -_import_structure = { - "configuration_olmo": ["OlmoConfig"], -} - -try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_olmo"] = [ - "OlmoForCausalLM", - "OlmoModel", - "OlmoPreTrainedModel", - ] - if TYPE_CHECKING: - from .configuration_olmo import OlmoConfig - - try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_olmo import ( - OlmoForCausalLM, - OlmoModel, - OlmoPreTrainedModel, - ) - + from .configuration_olmo import * + from .modeling_olmo import * else: import sys - sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) + _file = globals()["__file__"] + sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) diff --git a/src/transformers/models/olmo/configuration_olmo.py b/src/transformers/models/olmo/configuration_olmo.py index 77a3b18e364e..ac433d81d89d 100644 --- a/src/transformers/models/olmo/configuration_olmo.py +++ b/src/transformers/models/olmo/configuration_olmo.py @@ -179,3 +179,6 @@ def _rope_scaling_validation(self): ) if rope_scaling_factor is None or not isinstance(rope_scaling_factor, float) or rope_scaling_factor <= 1.0: raise ValueError(f"`rope_scaling`'s factor field must be a float > 1, got {rope_scaling_factor}") + + +__all__ = ['OlmoConfig'] \ No newline at end of file diff --git a/src/transformers/models/olmo/modeling_olmo.py b/src/transformers/models/olmo/modeling_olmo.py index 39bfa726deee..f6b0483a2f01 100644 --- a/src/transformers/models/olmo/modeling_olmo.py +++ b/src/transformers/models/olmo/modeling_olmo.py @@ -843,3 +843,6 @@ def forward( hidden_states=outputs.hidden_states, attentions=outputs.attentions, ) + + +__all__ = ['OlmoForCausalLM', 'OlmoModel', 'OlmoPreTrainedModel'] \ No newline at end of file diff --git a/src/transformers/models/phi/__init__.py b/src/transformers/models/phi/__init__.py index 662c0a9bf348..fb9784cd094f 100644 --- a/src/transformers/models/phi/__init__.py +++ b/src/transformers/models/phi/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2023 Microsoft and The HuggingFace Inc. team. All rights reserved. +# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -11,57 +11,17 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - from typing import TYPE_CHECKING -from ...utils import ( - OptionalDependencyNotAvailable, - _LazyModule, - is_sentencepiece_available, - is_tokenizers_available, - is_torch_available, -) - - -_import_structure = { - "configuration_phi": ["PhiConfig"], -} - -try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_phi"] = [ - "PhiPreTrainedModel", - "PhiModel", - "PhiForCausalLM", - "PhiForSequenceClassification", - "PhiForTokenClassification", - ] +from ...utils import _LazyModule +from ...utils.import_utils import define_import_structure if TYPE_CHECKING: - from .configuration_phi import PhiConfig - - try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_phi import ( - PhiForCausalLM, - PhiForSequenceClassification, - PhiForTokenClassification, - PhiModel, - PhiPreTrainedModel, - ) - - + from .modeling_phi import * + from .configuration_phi import * else: import sys - sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) + _file = globals()["__file__"] + sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) diff --git a/src/transformers/models/phi/configuration_phi.py b/src/transformers/models/phi/configuration_phi.py index 6c871b7ea54f..0f2d70a2bc85 100644 --- a/src/transformers/models/phi/configuration_phi.py +++ b/src/transformers/models/phi/configuration_phi.py @@ -198,3 +198,6 @@ def __init__( tie_word_embeddings=tie_word_embeddings, **kwargs, ) + + +__all__ = ['PhiConfig'] \ No newline at end of file diff --git a/src/transformers/models/phi/modeling_phi.py b/src/transformers/models/phi/modeling_phi.py index 5aa038d3ccfa..cda743a356c7 100644 --- a/src/transformers/models/phi/modeling_phi.py +++ b/src/transformers/models/phi/modeling_phi.py @@ -1033,3 +1033,6 @@ def forward( hidden_states=outputs.hidden_states, attentions=outputs.attentions, ) + + +__all__ = ['PhiPreTrainedModel', 'PhiModel', 'PhiForCausalLM', 'PhiForSequenceClassification', 'PhiForTokenClassification'] \ No newline at end of file diff --git a/src/transformers/models/qwen2/__init__.py b/src/transformers/models/qwen2/__init__.py index 301531655a1d..5b35d74181db 100644 --- a/src/transformers/models/qwen2/__init__.py +++ b/src/transformers/models/qwen2/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2024 The Qwen Team and The HuggingFace Inc. team. All rights reserved. +# Copyright 2025 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,72 +13,17 @@ # limitations under the License. from typing import TYPE_CHECKING -from ...utils import ( - OptionalDependencyNotAvailable, - _LazyModule, - is_tokenizers_available, - is_torch_available, -) - - -_import_structure = { - "configuration_qwen2": ["Qwen2Config"], - "tokenization_qwen2": ["Qwen2Tokenizer"], -} - -try: - if not is_tokenizers_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["tokenization_qwen2_fast"] = ["Qwen2TokenizerFast"] - -try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() -except OptionalDependencyNotAvailable: - pass -else: - _import_structure["modeling_qwen2"] = [ - "Qwen2ForCausalLM", - "Qwen2ForQuestionAnswering", - "Qwen2Model", - "Qwen2PreTrainedModel", - "Qwen2ForSequenceClassification", - "Qwen2ForTokenClassification", - ] +from ...utils import _LazyModule +from ...utils.import_utils import define_import_structure if TYPE_CHECKING: - from .configuration_qwen2 import Qwen2Config - from .tokenization_qwen2 import Qwen2Tokenizer - - try: - if not is_tokenizers_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .tokenization_qwen2_fast import Qwen2TokenizerFast - - try: - if not is_torch_available(): - raise OptionalDependencyNotAvailable() - except OptionalDependencyNotAvailable: - pass - else: - from .modeling_qwen2 import ( - Qwen2ForCausalLM, - Qwen2ForQuestionAnswering, - Qwen2ForSequenceClassification, - Qwen2ForTokenClassification, - Qwen2Model, - Qwen2PreTrainedModel, - ) - - + from .tokenization_qwen2 import * + from .configuration_qwen2 import * + from .modeling_qwen2 import * + from .tokenization_qwen2_fast import * else: import sys - sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__) + _file = globals()["__file__"] + sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__) diff --git a/src/transformers/models/qwen2/configuration_qwen2.py b/src/transformers/models/qwen2/configuration_qwen2.py index 16ce924b9f16..616fc24bfda0 100644 --- a/src/transformers/models/qwen2/configuration_qwen2.py +++ b/src/transformers/models/qwen2/configuration_qwen2.py @@ -194,3 +194,6 @@ def __init__( tie_word_embeddings=tie_word_embeddings, **kwargs, ) + + +__all__ = ['Qwen2Config'] \ No newline at end of file diff --git a/src/transformers/models/qwen2/modeling_qwen2.py b/src/transformers/models/qwen2/modeling_qwen2.py index 5dba7594e7e9..7e3544dc0508 100644 --- a/src/transformers/models/qwen2/modeling_qwen2.py +++ b/src/transformers/models/qwen2/modeling_qwen2.py @@ -1130,3 +1130,6 @@ def forward( hidden_states=outputs.hidden_states, attentions=outputs.attentions, ) + + +__all__ = ['Qwen2ForCausalLM', 'Qwen2ForQuestionAnswering', 'Qwen2Model', 'Qwen2PreTrainedModel', 'Qwen2ForSequenceClassification', 'Qwen2ForTokenClassification'] \ No newline at end of file diff --git a/src/transformers/models/qwen2/tokenization_qwen2.py b/src/transformers/models/qwen2/tokenization_qwen2.py index be2685430f64..78e758efeff1 100644 --- a/src/transformers/models/qwen2/tokenization_qwen2.py +++ b/src/transformers/models/qwen2/tokenization_qwen2.py @@ -337,3 +337,6 @@ def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = def prepare_for_tokenization(self, text, **kwargs): text = unicodedata.normalize("NFC", text) return (text, kwargs) + + +__all__ = ['Qwen2Tokenizer'] \ No newline at end of file diff --git a/src/transformers/models/qwen2/tokenization_qwen2_fast.py b/src/transformers/models/qwen2/tokenization_qwen2_fast.py index fcfc4ab764da..ad6c0cf7a281 100644 --- a/src/transformers/models/qwen2/tokenization_qwen2_fast.py +++ b/src/transformers/models/qwen2/tokenization_qwen2_fast.py @@ -132,3 +132,6 @@ def __init__( def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None) -> Tuple[str]: files = self._tokenizer.model.save(save_directory, name=filename_prefix) return tuple(files) + + +__all__ = ['Qwen2TokenizerFast'] \ No newline at end of file