Applies the rest of the init refactor except to modular files (#35238)

* [test_all] Applies the rest of the init refactor except to modular files

* Revert modular that doesn't work

* [test_all] TFGPT2Tokenizer
This commit is contained in:
Lysandre Debut
2025-01-05 18:30:08 +01:00
committed by GitHub
parent e5fd865eba
commit b2f2977533
999 changed files with 5236 additions and 13244 deletions

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_audio_spectrogram_transformer import *
from .convert_audio_spectrogram_transformer_original_to_pytorch import *
from .feature_extraction_audio_spectrogram_transformer import *
from .modeling_audio_spectrogram_transformer import *
else:

View File

@@ -19,8 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_bark import *
from .convert_suno_to_hf import *
from .generation_configuration_bark import *
from .modeling_bark import *
from .processing_bark import *
else:

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_bart import *
from .convert_bart_original_pytorch_checkpoint_to_pytorch import *
from .modeling_bart import *
from .modeling_flax_bart import *
from .modeling_tf_bart import *

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_beit import *
from .convert_beit_unilm_to_pytorch import *
from .feature_extraction_beit import *
from .image_processing_beit import *
from .modeling_beit import *

View File

@@ -19,10 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_bert import *
from .convert_bert_original_tf2_checkpoint_to_pytorch import *
from .convert_bert_original_tf_checkpoint_to_pytorch import *
from .convert_bert_pytorch_checkpoint_to_original_tf import *
from .convert_bert_token_dropping_original_tf2_checkpoint_to_pytorch import *
from .modeling_bert import *
from .modeling_flax_bert import *
from .modeling_tf_bert import *

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_big_bird import *
from .convert_bigbird_original_tf_checkpoint_to_pytorch import *
from .modeling_big_bird import *
from .modeling_flax_big_bird import *
from .tokenization_big_bird import *

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_bigbird_pegasus import *
from .convert_bigbird_pegasus_tf_to_pytorch import *
from .modeling_bigbird_pegasus import *
else:
import sys

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_biogpt import *
from .convert_biogpt_original_pytorch_checkpoint_to_pytorch import *
from .modeling_biogpt import *
from .tokenization_biogpt import *
else:

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_bit import *
from .convert_bit_to_pytorch import *
from .image_processing_bit import *
from .modeling_bit import *
else:

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_blenderbot import *
from .convert_blenderbot_original_pytorch_checkpoint_to_pytorch import *
from .modeling_blenderbot import *
from .modeling_flax_blenderbot import *
from .modeling_tf_blenderbot import *

View File

@@ -19,12 +19,9 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_blip import *
from .convert_blip_original_pytorch_to_hf import *
from .image_processing_blip import *
from .modeling_blip import *
from .modeling_blip_text import *
from .modeling_tf_blip import *
from .modeling_tf_blip_text import *
from .processing_blip import *
else:
import sys

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_blip_2 import *
from .convert_blip_2_original_to_pytorch import *
from .modeling_blip_2 import *
from .processing_blip_2 import *
else:

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_bloom import *
from .convert_bloom_original_checkpoint_to_pytorch import *
from .modeling_bloom import *
from .modeling_flax_bloom import *
from .tokenization_bloom_fast import *

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_bros import *
from .convert_bros_to_pytorch import *
from .modeling_bros import *
from .processing_bros import *
else:

View File

@@ -18,7 +18,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .convert_byt5_original_tf_checkpoint_to_pytorch import *
from .tokenization_byt5 import *
else:
import sys

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_canine import *
from .convert_canine_original_tf_checkpoint_to_pytorch import *
from .modeling_canine import *
from .tokenization_canine import *
else:

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_chameleon import *
from .convert_chameleon_weights_to_hf import *
from .image_processing_chameleon import *
from .modeling_chameleon import *
from .processing_chameleon import *

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_chinese_clip import *
from .convert_chinese_clip_original_pytorch_to_hf import *
from .feature_extraction_chinese_clip import *
from .image_processing_chinese_clip import *
from .modeling_chinese_clip import *

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_clap import *
from .convert_clap_original_pytorch_to_hf import *
from .feature_extraction_clap import *
from .modeling_clap import *
from .processing_clap import *

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_clip import *
from .convert_clip_original_pytorch_to_hf import *
from .feature_extraction_clip import *
from .image_processing_clip import *
from .modeling_clip import *

View File

@@ -19,7 +19,6 @@ from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_clipseg import *
from .convert_clipseg_original_pytorch_to_hf import *
from .modeling_clipseg import *
from .processing_clipseg import *
else:

View File

@@ -1,4 +1,4 @@
# Copyright 2023 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,67 +13,18 @@
# limitations under the License.
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_torch_available,
)
_import_structure = {
"configuration_clvp": [
"ClvpConfig",
"ClvpDecoderConfig",
"ClvpEncoderConfig",
],
"feature_extraction_clvp": ["ClvpFeatureExtractor"],
"processing_clvp": ["ClvpProcessor"],
"tokenization_clvp": ["ClvpTokenizer"],
}
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_clvp"] = [
"ClvpModelForConditionalGeneration",
"ClvpForCausalLM",
"ClvpModel",
"ClvpPreTrainedModel",
"ClvpEncoder",
"ClvpDecoder",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_clvp import (
ClvpConfig,
ClvpDecoderConfig,
ClvpEncoderConfig,
)
from .feature_extraction_clvp import ClvpFeatureExtractor
from .processing_clvp import ClvpProcessor
from .tokenization_clvp import ClvpTokenizer
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_clvp import (
ClvpDecoder,
ClvpEncoder,
ClvpForCausalLM,
ClvpModel,
ClvpModelForConditionalGeneration,
ClvpPreTrainedModel,
)
from .configuration_clvp import *
from .feature_extraction_clvp import *
from .modeling_clvp import *
from .processing_clvp import *
from .tokenization_clvp 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__)

View File

@@ -438,3 +438,6 @@ class ClvpConfig(PretrainedConfig):
decoder_config=decoder_config.to_dict(),
**kwargs,
)
__all__ = ["ClvpConfig", "ClvpDecoderConfig", "ClvpEncoderConfig"]

View File

@@ -236,3 +236,6 @@ class ClvpFeatureExtractor(SequenceFeatureExtractor):
padded_inputs["input_features"] = input_features
return padded_inputs.convert_to_tensors(return_tensors)
__all__ = ["ClvpFeatureExtractor"]

View File

@@ -2021,3 +2021,13 @@ class ClvpModelForConditionalGeneration(ClvpPreTrainedModel, GenerationMixin):
text_encoder_hidden_states=text_outputs.hidden_states,
speech_encoder_hidden_states=speech_outputs.hidden_states,
)
__all__ = [
"ClvpModelForConditionalGeneration",
"ClvpForCausalLM",
"ClvpModel",
"ClvpPreTrainedModel",
"ClvpEncoder",
"ClvpDecoder",
]

View File

@@ -88,3 +88,6 @@ class ClvpProcessor(ProcessorMixin):
the docstring of this method for more information.
"""
return self.tokenizer.decode(*args, **kwargs)
__all__ = ["ClvpProcessor"]

View File

@@ -362,3 +362,6 @@ class ClvpTokenizer(PreTrainedTokenizer):
index += 1
return vocab_file, merge_file
__all__ = ["ClvpTokenizer"]

View File

@@ -1,4 +1,4 @@
# Copyright 2023 MetaAI and The HuggingFace Inc. team. All rights reserved.
# Copyright 2024 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,45 +13,15 @@
# limitations under the License.
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
_import_structure = {}
try:
if not is_sentencepiece_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_code_llama"] = ["CodeLlamaTokenizer"]
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_code_llama_fast"] = ["CodeLlamaTokenizerFast"]
if TYPE_CHECKING:
try:
if not is_sentencepiece_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_code_llama import CodeLlamaTokenizer
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_code_llama_fast import CodeLlamaTokenizerFast
from .tokenization_code_llama import *
from .tokenization_code_llama_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__)

View File

@@ -447,3 +447,6 @@ class CodeLlamaTokenizer(PreTrainedTokenizer):
self.__dict__ = d
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
self.sp_model.LoadFromSerializedProto(self.sp_model_proto)
__all__ = ["CodeLlamaTokenizer"]

View File

@@ -376,3 +376,6 @@ class CodeLlamaTokenizerFast(PreTrainedTokenizerFast):
if token_ids_1 is None:
return self.bos_token_id + token_ids_0 + self.eos_token_id
return self.bos_token_id + token_ids_0 + token_ids_1 + self.eos_token_id
__all__ = ["CodeLlamaTokenizerFast"]

View File

@@ -1,4 +1,4 @@
# Copyright 2022 Salesforce authors, The EleutherAI, and HuggingFace Teams. All rights reserved.
# Copyright 2024 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,59 +13,17 @@
# limitations under the License.
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
_import_structure = {
"configuration_codegen": ["CodeGenConfig", "CodeGenOnnxConfig"],
"tokenization_codegen": ["CodeGenTokenizer"],
}
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_codegen_fast"] = ["CodeGenTokenizerFast"]
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_codegen"] = [
"CodeGenForCausalLM",
"CodeGenModel",
"CodeGenPreTrainedModel",
]
if TYPE_CHECKING:
from .configuration_codegen import CodeGenConfig, CodeGenOnnxConfig
from .tokenization_codegen import CodeGenTokenizer
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_codegen_fast import CodeGenTokenizerFast
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_codegen import (
CodeGenForCausalLM,
CodeGenModel,
CodeGenPreTrainedModel,
)
from .configuration_codegen import *
from .modeling_codegen import *
from .tokenization_codegen import *
from .tokenization_codegen_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__)

View File

@@ -225,3 +225,6 @@ class CodeGenOnnxConfig(OnnxConfigWithPast):
@property
def default_onnx_opset(self) -> int:
return 13
__all__ = ["CodeGenConfig", "CodeGenOnnxConfig"]

View File

@@ -809,3 +809,6 @@ class CodeGenForCausalLM(CodeGenPreTrainedModel, GenerationMixin):
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past)
for layer_past in past_key_values
)
__all__ = ["CodeGenForCausalLM", "CodeGenModel", "CodeGenPreTrainedModel"]

View File

@@ -414,3 +414,6 @@ class CodeGenTokenizer(PreTrainedTokenizer):
return completion[: min(terminals_pos)]
else:
return completion
__all__ = ["CodeGenTokenizer"]

View File

@@ -270,3 +270,6 @@ class CodeGenTokenizerFast(PreTrainedTokenizerFast):
return completion[: min(terminals_pos)]
else:
return completion
__all__ = ["CodeGenTokenizerFast"]

View File

@@ -1,4 +1,4 @@
# Copyright 2024 Cohere and The HuggingFace Inc. team. All rights reserved.
# Copyright 2024 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,65 +13,16 @@
# 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_cohere": ["CohereConfig"],
}
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_cohere_fast"] = ["CohereTokenizerFast"]
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_cohere"] = [
"CohereForCausalLM",
"CohereModel",
"CoherePreTrainedModel",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_cohere import CohereConfig
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_cohere_fast import CohereTokenizerFast
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_cohere import (
CohereForCausalLM,
CohereModel,
CoherePreTrainedModel,
)
from .configuration_cohere import *
from .modeling_cohere import *
from .tokenization_cohere_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__)

View File

@@ -198,3 +198,6 @@ class CohereConfig(PretrainedConfig):
tie_word_embeddings=tie_word_embeddings,
**kwargs,
)
__all__ = ["CohereConfig"]

View File

@@ -1145,3 +1145,6 @@ class CohereForCausalLM(CoherePreTrainedModel, GenerationMixin):
hidden_states=outputs.hidden_states,
attentions=outputs.attentions,
)
__all__ = ["CohereForCausalLM", "CohereModel", "CoherePreTrainedModel"]

View File

@@ -510,3 +510,6 @@ class CohereTokenizerFast(PreTrainedTokenizerFast):
output = output + bos_token_id + token_ids_1 + eos_token_id
return output
__all__ = ["CohereTokenizerFast"]

View File

@@ -1,4 +1,4 @@
# Copyright 2022 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,71 +11,19 @@
# 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_torch_available, is_vision_available
_import_structure = {
"configuration_conditional_detr": [
"ConditionalDetrConfig",
"ConditionalDetrOnnxConfig",
]
}
try:
if not is_vision_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["feature_extraction_conditional_detr"] = ["ConditionalDetrFeatureExtractor"]
_import_structure["image_processing_conditional_detr"] = ["ConditionalDetrImageProcessor"]
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_conditional_detr"] = [
"ConditionalDetrForObjectDetection",
"ConditionalDetrForSegmentation",
"ConditionalDetrModel",
"ConditionalDetrPreTrainedModel",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_conditional_detr import (
ConditionalDetrConfig,
ConditionalDetrOnnxConfig,
)
try:
if not is_vision_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .feature_extraction_conditional_detr import ConditionalDetrFeatureExtractor
from .image_processing_conditional_detr import ConditionalDetrImageProcessor
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_conditional_detr import (
ConditionalDetrForObjectDetection,
ConditionalDetrForSegmentation,
ConditionalDetrModel,
ConditionalDetrPreTrainedModel,
)
from .configuration_conditional_detr import *
from .feature_extraction_conditional_detr import *
from .image_processing_conditional_detr import *
from .modeling_conditional_detr 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__)

View File

@@ -273,3 +273,6 @@ class ConditionalDetrOnnxConfig(OnnxConfig):
@property
def default_onnx_opset(self) -> int:
return 12
__all__ = ["ConditionalDetrConfig", "ConditionalDetrOnnxConfig"]

View File

@@ -41,3 +41,6 @@ class ConditionalDetrFeatureExtractor(ConditionalDetrImageProcessor):
FutureWarning,
)
super().__init__(*args, **kwargs)
__all__ = ["ConditionalDetrFeatureExtractor"]

View File

@@ -1851,3 +1851,6 @@ class ConditionalDetrImageProcessor(BaseImageProcessor):
results.append({"segmentation": segmentation, "segments_info": segments})
return results
__all__ = ["ConditionalDetrImageProcessor"]

View File

@@ -2105,3 +2105,11 @@ class ConditionalDetrMHAttentionMap(nn.Module):
weights = nn.functional.softmax(weights.flatten(2), dim=-1).view(weights.size())
weights = self.dropout(weights)
return weights
__all__ = [
"ConditionalDetrForObjectDetection",
"ConditionalDetrForSegmentation",
"ConditionalDetrModel",
"ConditionalDetrPreTrainedModel",
]

View File

@@ -1,4 +1,4 @@
# Copyright 2020 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,114 +13,18 @@
# limitations under the License.
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_tokenizers_available,
is_torch_available,
)
_import_structure = {
"configuration_convbert": ["ConvBertConfig", "ConvBertOnnxConfig"],
"tokenization_convbert": ["ConvBertTokenizer"],
}
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_convbert_fast"] = ["ConvBertTokenizerFast"]
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_convbert"] = [
"ConvBertForMaskedLM",
"ConvBertForMultipleChoice",
"ConvBertForQuestionAnswering",
"ConvBertForSequenceClassification",
"ConvBertForTokenClassification",
"ConvBertLayer",
"ConvBertModel",
"ConvBertPreTrainedModel",
"load_tf_weights_in_convbert",
]
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_convbert"] = [
"TFConvBertForMaskedLM",
"TFConvBertForMultipleChoice",
"TFConvBertForQuestionAnswering",
"TFConvBertForSequenceClassification",
"TFConvBertForTokenClassification",
"TFConvBertLayer",
"TFConvBertModel",
"TFConvBertPreTrainedModel",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_convbert import ConvBertConfig, ConvBertOnnxConfig
from .tokenization_convbert import ConvBertTokenizer
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_convbert_fast import ConvBertTokenizerFast
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_convbert import (
ConvBertForMaskedLM,
ConvBertForMultipleChoice,
ConvBertForQuestionAnswering,
ConvBertForSequenceClassification,
ConvBertForTokenClassification,
ConvBertLayer,
ConvBertModel,
ConvBertPreTrainedModel,
load_tf_weights_in_convbert,
)
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_convbert import (
TFConvBertForMaskedLM,
TFConvBertForMultipleChoice,
TFConvBertForQuestionAnswering,
TFConvBertForSequenceClassification,
TFConvBertForTokenClassification,
TFConvBertLayer,
TFConvBertModel,
TFConvBertPreTrainedModel,
)
from .configuration_convbert import *
from .modeling_convbert import *
from .modeling_tf_convbert import *
from .tokenization_convbert import *
from .tokenization_convbert_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__)

View File

@@ -155,3 +155,6 @@ class ConvBertOnnxConfig(OnnxConfig):
("token_type_ids", dynamic_axis),
]
)
__all__ = ["ConvBertConfig", "ConvBertOnnxConfig"]

View File

@@ -1331,3 +1331,16 @@ class ConvBertForQuestionAnswering(ConvBertPreTrainedModel):
hidden_states=outputs.hidden_states,
attentions=outputs.attentions,
)
__all__ = [
"ConvBertForMaskedLM",
"ConvBertForMultipleChoice",
"ConvBertForQuestionAnswering",
"ConvBertForSequenceClassification",
"ConvBertForTokenClassification",
"ConvBertLayer",
"ConvBertModel",
"ConvBertPreTrainedModel",
"load_tf_weights_in_convbert",
]

View File

@@ -1462,3 +1462,15 @@ class TFConvBertForQuestionAnswering(TFConvBertPreTrainedModel, TFQuestionAnswer
if getattr(self, "qa_outputs", None) is not None:
with tf.name_scope(self.qa_outputs.name):
self.qa_outputs.build([None, None, self.config.hidden_size])
__all__ = [
"TFConvBertForMaskedLM",
"TFConvBertForMultipleChoice",
"TFConvBertForQuestionAnswering",
"TFConvBertForSequenceClassification",
"TFConvBertForTokenClassification",
"TFConvBertLayer",
"TFConvBertModel",
"TFConvBertPreTrainedModel",
]

View File

@@ -507,3 +507,6 @@ class WordpieceTokenizer:
else:
output_tokens.extend(sub_tokens)
return output_tokens
__all__ = ["ConvBertTokenizer"]

View File

@@ -171,3 +171,6 @@ class ConvBertTokenizerFast(PreTrainedTokenizerFast):
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__ = ["ConvBertTokenizerFast"]

View File

@@ -1,4 +1,4 @@
# Copyright 2022 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,86 +13,18 @@
# limitations under the License.
from typing import TYPE_CHECKING
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_tf_available,
is_torch_available,
is_vision_available,
)
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
_import_structure = {"configuration_convnext": ["ConvNextConfig", "ConvNextOnnxConfig"]}
try:
if not is_vision_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["feature_extraction_convnext"] = ["ConvNextFeatureExtractor"]
_import_structure["image_processing_convnext"] = ["ConvNextImageProcessor"]
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_convnext"] = [
"ConvNextForImageClassification",
"ConvNextModel",
"ConvNextPreTrainedModel",
"ConvNextBackbone",
]
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_convnext"] = [
"TFConvNextForImageClassification",
"TFConvNextModel",
"TFConvNextPreTrainedModel",
]
if TYPE_CHECKING:
from .configuration_convnext import ConvNextConfig, ConvNextOnnxConfig
try:
if not is_vision_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .feature_extraction_convnext import ConvNextFeatureExtractor
from .image_processing_convnext import ConvNextImageProcessor
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_convnext import (
ConvNextBackbone,
ConvNextForImageClassification,
ConvNextModel,
ConvNextPreTrainedModel,
)
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_convnext import TFConvNextForImageClassification, TFConvNextModel, TFConvNextPreTrainedModel
from .configuration_convnext import *
from .feature_extraction_convnext import *
from .image_processing_convnext import *
from .modeling_convnext import *
from .modeling_tf_convnext import *
else:
import sys
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)
_file = globals()["__file__"]
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)

View File

@@ -137,3 +137,6 @@ class ConvNextOnnxConfig(OnnxConfig):
@property
def atol_for_validation(self) -> float:
return 1e-5
__all__ = ["ConvNextConfig", "ConvNextOnnxConfig"]

View File

@@ -31,3 +31,6 @@ class ConvNextFeatureExtractor(ConvNextImageProcessor):
FutureWarning,
)
super().__init__(*args, **kwargs)
__all__ = ["ConvNextFeatureExtractor"]

View File

@@ -318,3 +318,6 @@ class ConvNextImageProcessor(BaseImageProcessor):
data = {"pixel_values": images}
return BatchFeature(data=data, tensor_type=return_tensors)
__all__ = ["ConvNextImageProcessor"]

View File

@@ -546,3 +546,6 @@ class ConvNextBackbone(ConvNextPreTrainedModel, BackboneMixin):
hidden_states=hidden_states if output_hidden_states else None,
attentions=None,
)
__all__ = ["ConvNextForImageClassification", "ConvNextModel", "ConvNextPreTrainedModel", "ConvNextBackbone"]

View File

@@ -664,3 +664,6 @@ class TFConvNextForImageClassification(TFConvNextPreTrainedModel, TFSequenceClas
if hasattr(self.classifier, "name"):
with tf.name_scope(self.classifier.name):
self.classifier.build([None, None, self.config.hidden_sizes[-1]])
__all__ = ["TFConvNextForImageClassification", "TFConvNextModel", "TFConvNextPreTrainedModel"]

View File

@@ -1,8 +1,4 @@
# flake8: noqa
# There's no way to ignore "F401 '...' imported but unused" warnings in this
# module, but to preserve other warnings. So, don't check this module at all.
# Copyright 2023 The HuggingFace Team. All rights reserved.
# Copyright 2024 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.
@@ -17,73 +13,16 @@
# limitations under the License.
from typing import TYPE_CHECKING
# rely on isort to merge the imports
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_torch_available,
is_tf_available,
)
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
_import_structure = {"configuration_convnextv2": ["ConvNextV2Config"]}
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_convnextv2"] = [
"ConvNextV2ForImageClassification",
"ConvNextV2Model",
"ConvNextV2PreTrainedModel",
"ConvNextV2Backbone",
]
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_convnextv2"] = [
"TFConvNextV2ForImageClassification",
"TFConvNextV2Model",
"TFConvNextV2PreTrainedModel",
]
if TYPE_CHECKING:
from .configuration_convnextv2 import (
ConvNextV2Config,
)
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_convnextv2 import (
ConvNextV2Backbone,
ConvNextV2ForImageClassification,
ConvNextV2Model,
ConvNextV2PreTrainedModel,
)
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_convnextv2 import (
TFConvNextV2ForImageClassification,
TFConvNextV2Model,
TFConvNextV2PreTrainedModel,
)
from .configuration_convnextv2 import *
from .modeling_convnextv2 import *
from .modeling_tf_convnextv2 import *
else:
import sys
sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure)
_file = globals()["__file__"]
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)

View File

@@ -113,3 +113,6 @@ class ConvNextV2Config(BackboneConfigMixin, PretrainedConfig):
self._out_features, self._out_indices = get_aligned_output_features_output_indices(
out_features=out_features, out_indices=out_indices, stage_names=self.stage_names
)
__all__ = ["ConvNextV2Config"]

View File

@@ -569,3 +569,6 @@ class ConvNextV2Backbone(ConvNextV2PreTrainedModel, BackboneMixin):
hidden_states=hidden_states if output_hidden_states else None,
attentions=None,
)
__all__ = ["ConvNextV2ForImageClassification", "ConvNextV2Model", "ConvNextV2PreTrainedModel", "ConvNextV2Backbone"]

View File

@@ -678,3 +678,6 @@ class TFConvNextV2ForImageClassification(TFConvNextV2PreTrainedModel, TFSequence
if getattr(self, "classifier", None) is not None:
with tf.name_scope(self.classifier.name):
self.classifier.build([None, None, self.config.hidden_sizes[-1]])
__all__ = ["TFConvNextV2ForImageClassification", "TFConvNextV2Model", "TFConvNextV2PreTrainedModel"]

View File

@@ -1,4 +1,4 @@
# Copyright 2020 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,49 +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
_import_structure = {}
try:
if not is_sentencepiece_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_cpm"] = ["CpmTokenizer"]
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_cpm_fast"] = ["CpmTokenizerFast"]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
try:
if not is_sentencepiece_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_cpm import CpmTokenizer
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_cpm_fast import CpmTokenizerFast
from .tokenization_cpm import *
from .tokenization_cpm_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__)

View File

@@ -343,3 +343,6 @@ class CpmTokenizer(PreTrainedTokenizer):
text = super()._decode(*args, **kwargs)
text = text.replace(" ", "").replace("\u2582", " ").replace("\u2583", "\n")
return text
__all__ = ["CpmTokenizer"]

View File

@@ -236,3 +236,6 @@ class CpmTokenizerFast(PreTrainedTokenizerFast):
text = super()._decode(*args, **kwargs)
text = text.replace(" ", "").replace("\u2582", " ").replace("\u2583", "\n")
return text
__all__ = ["CpmTokenizerFast"]

View File

@@ -1,8 +1,4 @@
# flake8: noqa
# There's no way to ignore "F401 '...' imported but unused" warnings in this
# module, but to preserve other warnings. So, don't check this module at all.
# Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved.
# Copyright 2024 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.
@@ -17,46 +13,16 @@
# limitations under the License.
from typing import TYPE_CHECKING
# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available
_import_structure = {
"configuration_cpmant": ["CpmAntConfig"],
"tokenization_cpmant": ["CpmAntTokenizer"],
}
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_cpmant"] = [
"CpmAntForCausalLM",
"CpmAntModel",
"CpmAntPreTrainedModel",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_cpmant import CpmAntConfig
from .tokenization_cpmant import CpmAntTokenizer
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_cpmant import (
CpmAntForCausalLM,
CpmAntModel,
CpmAntPreTrainedModel,
)
from .configuration_cpmant import *
from .modeling_cpmant import *
from .tokenization_cpmant 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__)

View File

@@ -117,3 +117,6 @@ class CpmAntConfig(PretrainedConfig):
self.use_cache = use_cache
self.vocab_size = vocab_size
self.init_std = init_std
__all__ = ["CpmAntConfig"]

View File

@@ -855,3 +855,6 @@ class CpmAntForCausalLM(CpmAntPreTrainedModel, GenerationMixin):
key_value_layer[0] = key_value_layer[0][beam_idx]
key_value_layer[1] = key_value_layer[1][beam_idx]
return past_key_values
__all__ = ["CpmAntForCausalLM", "CpmAntModel", "CpmAntPreTrainedModel"]

View File

@@ -265,3 +265,6 @@ class CpmAntTokenizer(PreTrainedTokenizer):
if token_ids_1 is not None:
return [1] + ([0] * len(token_ids_0)) + [1] + ([0] * len(token_ids_1))
return [1] + ([0] * len(token_ids_0))
__all__ = ["CpmAntTokenizer"]

View File

@@ -1,4 +1,4 @@
# Copyright 2020 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,75 +11,19 @@
# 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_tf_available, is_torch_available
_import_structure = {
"configuration_ctrl": ["CTRLConfig"],
"tokenization_ctrl": ["CTRLTokenizer"],
}
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_ctrl"] = [
"CTRLForSequenceClassification",
"CTRLLMHeadModel",
"CTRLModel",
"CTRLPreTrainedModel",
]
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_ctrl"] = [
"TFCTRLForSequenceClassification",
"TFCTRLLMHeadModel",
"TFCTRLModel",
"TFCTRLPreTrainedModel",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_ctrl import CTRLConfig
from .tokenization_ctrl import CTRLTokenizer
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_ctrl import (
CTRLForSequenceClassification,
CTRLLMHeadModel,
CTRLModel,
CTRLPreTrainedModel,
)
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_ctrl import (
TFCTRLForSequenceClassification,
TFCTRLLMHeadModel,
TFCTRLModel,
TFCTRLPreTrainedModel,
)
from .configuration_ctrl import *
from .modeling_ctrl import *
from .modeling_tf_ctrl import *
from .tokenization_ctrl 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__)

View File

@@ -111,3 +111,6 @@ class CTRLConfig(PretrainedConfig):
self.use_cache = use_cache
super().__init__(**kwargs)
__all__ = ["CTRLConfig"]

View File

@@ -839,3 +839,6 @@ class CTRLForSequenceClassification(CTRLPreTrainedModel):
hidden_states=transformer_outputs.hidden_states,
attentions=transformer_outputs.attentions,
)
__all__ = ["CTRLForSequenceClassification", "CTRLLMHeadModel", "CTRLModel", "CTRLPreTrainedModel"]

View File

@@ -926,3 +926,6 @@ class TFCTRLForSequenceClassification(TFCTRLPreTrainedModel, TFSequenceClassific
if getattr(self, "transformer", None) is not None:
with tf.name_scope(self.transformer.name):
self.transformer.build(None)
__all__ = ["TFCTRLForSequenceClassification", "TFCTRLLMHeadModel", "TFCTRLModel", "TFCTRLPreTrainedModel"]

View File

@@ -246,3 +246,6 @@ class CTRLTokenizer(PreTrainedTokenizer):
# tokens_generated_so_far = re.sub('(@@ )', '', string=filtered_tokens)
# tokens_generated_so_far = re.sub('(@@ ?$)', '', string=tokens_generated_so_far)
# return ''.join(tokens_generated_so_far)
__all__ = ["CTRLTokenizer"]

View File

@@ -1,4 +1,4 @@
# Copyright 2022 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,65 +13,16 @@
# limitations under the License.
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
_import_structure = {"configuration_cvt": ["CvtConfig"]}
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_cvt"] = [
"CvtForImageClassification",
"CvtModel",
"CvtPreTrainedModel",
]
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_cvt"] = [
"TFCvtForImageClassification",
"TFCvtModel",
"TFCvtPreTrainedModel",
]
if TYPE_CHECKING:
from .configuration_cvt import CvtConfig
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_cvt import (
CvtForImageClassification,
CvtModel,
CvtPreTrainedModel,
)
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_cvt import (
TFCvtForImageClassification,
TFCvtModel,
TFCvtPreTrainedModel,
)
from .configuration_cvt import *
from .modeling_cvt import *
from .modeling_tf_cvt 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__)

View File

@@ -141,3 +141,6 @@ class CvtConfig(PretrainedConfig):
self.stride_q = stride_q
self.initializer_range = initializer_range
self.layer_norm_eps = layer_norm_eps
__all__ = ["CvtConfig"]

View File

@@ -720,3 +720,6 @@ class CvtForImageClassification(CvtPreTrainedModel):
return ((loss,) + output) if loss is not None else output
return ImageClassifierOutputWithNoAttention(loss=loss, logits=logits, hidden_states=outputs.hidden_states)
__all__ = ["CvtForImageClassification", "CvtModel", "CvtPreTrainedModel"]

View File

@@ -1091,3 +1091,6 @@ class TFCvtForImageClassification(TFCvtPreTrainedModel, TFSequenceClassification
if hasattr(self.classifier, "name"):
with tf.name_scope(self.classifier.name):
self.classifier.build([None, None, self.config.embed_dim[-1]])
__all__ = ["TFCvtForImageClassification", "TFCvtModel", "TFCvtPreTrainedModel"]

View File

@@ -1,5 +1,4 @@
# coding=utf-8
# Copyright 2024 Descript and The HuggingFace Inc. team. All rights reserved.
# Copyright 2024 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.
@@ -14,47 +13,16 @@
# 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_dac": ["DacConfig"],
"feature_extraction_dac": ["DacFeatureExtractor"],
}
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_dac"] = [
"DacModel",
"DacPreTrainedModel",
]
if TYPE_CHECKING:
from .configuration_dac import (
DacConfig,
)
from .feature_extraction_dac import DacFeatureExtractor
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_dac import (
DacModel,
DacPreTrainedModel,
)
from .configuration_dac import *
from .feature_extraction_dac import *
from .modeling_dac 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__)

View File

@@ -109,3 +109,6 @@ class DacConfig(PretrainedConfig):
def frame_rate(self) -> int:
hop_length = np.prod(self.upsampling_ratios)
return math.ceil(self.sampling_rate / hop_length)
__all__ = ["DacConfig"]

View File

@@ -168,3 +168,6 @@ class DacFeatureExtractor(SequenceFeatureExtractor):
padded_inputs = padded_inputs.convert_to_tensors(return_tensors)
return padded_inputs
__all__ = ["DacFeatureExtractor"]

View File

@@ -719,3 +719,6 @@ class DacModel(DacPreTrainedModel):
return (loss, audio_values, quantized_representation, audio_codes, projected_latents)
return DacOutput(loss, audio_values, quantized_representation, audio_codes, projected_latents)
__all__ = ["DacModel", "DacPreTrainedModel"]

View File

@@ -1,4 +1,4 @@
# Copyright 2022 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,115 +11,22 @@
# 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_tf_available, is_torch_available
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
_import_structure = {
"configuration_data2vec_audio": ["Data2VecAudioConfig"],
"configuration_data2vec_text": [
"Data2VecTextConfig",
"Data2VecTextOnnxConfig",
],
"configuration_data2vec_vision": [
"Data2VecVisionConfig",
"Data2VecVisionOnnxConfig",
],
}
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_data2vec_audio"] = [
"Data2VecAudioForAudioFrameClassification",
"Data2VecAudioForCTC",
"Data2VecAudioForSequenceClassification",
"Data2VecAudioForXVector",
"Data2VecAudioModel",
"Data2VecAudioPreTrainedModel",
]
_import_structure["modeling_data2vec_text"] = [
"Data2VecTextForCausalLM",
"Data2VecTextForMaskedLM",
"Data2VecTextForMultipleChoice",
"Data2VecTextForQuestionAnswering",
"Data2VecTextForSequenceClassification",
"Data2VecTextForTokenClassification",
"Data2VecTextModel",
"Data2VecTextPreTrainedModel",
]
_import_structure["modeling_data2vec_vision"] = [
"Data2VecVisionForImageClassification",
"Data2VecVisionForMaskedImageModeling",
"Data2VecVisionForSemanticSegmentation",
"Data2VecVisionModel",
"Data2VecVisionPreTrainedModel",
]
if is_tf_available():
_import_structure["modeling_tf_data2vec_vision"] = [
"TFData2VecVisionForImageClassification",
"TFData2VecVisionForSemanticSegmentation",
"TFData2VecVisionModel",
"TFData2VecVisionPreTrainedModel",
]
if TYPE_CHECKING:
from .configuration_data2vec_audio import Data2VecAudioConfig
from .configuration_data2vec_text import (
Data2VecTextConfig,
Data2VecTextOnnxConfig,
)
from .configuration_data2vec_vision import (
Data2VecVisionConfig,
Data2VecVisionOnnxConfig,
)
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_data2vec_audio import (
Data2VecAudioForAudioFrameClassification,
Data2VecAudioForCTC,
Data2VecAudioForSequenceClassification,
Data2VecAudioForXVector,
Data2VecAudioModel,
Data2VecAudioPreTrainedModel,
)
from .modeling_data2vec_text import (
Data2VecTextForCausalLM,
Data2VecTextForMaskedLM,
Data2VecTextForMultipleChoice,
Data2VecTextForQuestionAnswering,
Data2VecTextForSequenceClassification,
Data2VecTextForTokenClassification,
Data2VecTextModel,
Data2VecTextPreTrainedModel,
)
from .modeling_data2vec_vision import (
Data2VecVisionForImageClassification,
Data2VecVisionForMaskedImageModeling,
Data2VecVisionForSemanticSegmentation,
Data2VecVisionModel,
Data2VecVisionPreTrainedModel,
)
if is_tf_available():
from .modeling_tf_data2vec_vision import (
TFData2VecVisionForImageClassification,
TFData2VecVisionForSemanticSegmentation,
TFData2VecVisionModel,
TFData2VecVisionPreTrainedModel,
)
from .configuration_data2vec_audio import *
from .configuration_data2vec_text import *
from .configuration_data2vec_vision import *
from .modeling_data2vec_audio import *
from .modeling_data2vec_text import *
from .modeling_data2vec_vision import *
from .modeling_tf_data2vec_vision 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__)

View File

@@ -283,3 +283,6 @@ class Data2VecAudioConfig(PretrainedConfig):
@property
def inputs_to_logits_ratio(self):
return math.prod(self.conv_stride)
__all__ = ["Data2VecAudioConfig"]

View File

@@ -149,3 +149,6 @@ class Data2VecTextOnnxConfig(OnnxConfig):
("attention_mask", dynamic_axis),
]
)
__all__ = ["Data2VecTextConfig", "Data2VecTextOnnxConfig"]

View File

@@ -189,3 +189,6 @@ class Data2VecVisionOnnxConfig(OnnxConfig):
@property
def atol_for_validation(self) -> float:
return 1e-4
__all__ = ["Data2VecVisionConfig", "Data2VecVisionOnnxConfig"]

View File

@@ -1763,3 +1763,13 @@ class Data2VecAudioForXVector(Data2VecAudioPreTrainedModel):
hidden_states=outputs.hidden_states,
attentions=outputs.attentions,
)
__all__ = [
"Data2VecAudioForAudioFrameClassification",
"Data2VecAudioForCTC",
"Data2VecAudioForSequenceClassification",
"Data2VecAudioForXVector",
"Data2VecAudioModel",
"Data2VecAudioPreTrainedModel",
]

View File

@@ -1539,3 +1539,15 @@ def create_position_ids_from_input_ids(input_ids, padding_idx, past_key_values_l
mask = input_ids.ne(padding_idx).int()
incremental_indices = (torch.cumsum(mask, dim=1).type_as(mask) + past_key_values_length) * mask
return incremental_indices.long() + padding_idx
__all__ = [
"Data2VecTextForCausalLM",
"Data2VecTextForMaskedLM",
"Data2VecTextForMultipleChoice",
"Data2VecTextForQuestionAnswering",
"Data2VecTextForSequenceClassification",
"Data2VecTextForTokenClassification",
"Data2VecTextModel",
"Data2VecTextPreTrainedModel",
]

View File

@@ -1444,3 +1444,11 @@ class Data2VecVisionForSemanticSegmentation(Data2VecVisionPreTrainedModel):
hidden_states=outputs.hidden_states if output_hidden_states else None,
attentions=outputs.attentions,
)
__all__ = [
"Data2VecVisionForImageClassification",
"Data2VecVisionForSemanticSegmentation",
"Data2VecVisionModel",
"Data2VecVisionPreTrainedModel",
]

View File

@@ -1714,3 +1714,11 @@ class TFData2VecVisionForSemanticSegmentation(TFData2VecVisionPreTrainedModel):
if getattr(self, "fpn2", None) is not None:
with tf.name_scope(self.fpn2[0].name):
self.fpn2[0].build([None, None, None, self.config.hidden_size])
__all__ = [
"TFData2VecVisionForImageClassification",
"TFData2VecVisionForSemanticSegmentation",
"TFData2VecVisionModel",
"TFData2VecVisionPreTrainedModel",
]

View File

@@ -13,39 +13,15 @@
# limitations under the License.
from typing import TYPE_CHECKING
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available
_import_structure = {
"configuration_dbrx": ["DbrxConfig"],
}
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_dbrx"] = [
"DbrxForCausalLM",
"DbrxModel",
"DbrxPreTrainedModel",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_dbrx import DbrxConfig
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_dbrx import DbrxForCausalLM, DbrxModel, DbrxPreTrainedModel
from .configuration_dbrx import *
from .modeling_dbrx 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__)

View File

@@ -227,3 +227,6 @@ class DbrxConfig(PretrainedConfig):
raise ValueError("tie_word_embeddings is not supported for DBRX models.")
super().__init__(tie_word_embeddings=tie_word_embeddings, **kwargs)
__all__ = ["DbrxConfig"]

View File

@@ -1374,3 +1374,6 @@ class DbrxForCausalLM(DbrxPreTrainedModel, GenerationMixin):
attentions=outputs.attentions,
router_logits=outputs.router_logits,
)
__all__ = ["DbrxForCausalLM", "DbrxModel", "DbrxPreTrainedModel"]

View File

@@ -1,4 +1,4 @@
# Copyright 2020 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,106 +11,20 @@
# 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_tf_available,
is_tokenizers_available,
is_torch_available,
)
_import_structure = {
"configuration_deberta": ["DebertaConfig", "DebertaOnnxConfig"],
"tokenization_deberta": ["DebertaTokenizer"],
}
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_deberta_fast"] = ["DebertaTokenizerFast"]
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_deberta"] = [
"DebertaForMaskedLM",
"DebertaForQuestionAnswering",
"DebertaForSequenceClassification",
"DebertaForTokenClassification",
"DebertaModel",
"DebertaPreTrainedModel",
]
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_deberta"] = [
"TFDebertaForMaskedLM",
"TFDebertaForQuestionAnswering",
"TFDebertaForSequenceClassification",
"TFDebertaForTokenClassification",
"TFDebertaModel",
"TFDebertaPreTrainedModel",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_deberta import DebertaConfig, DebertaOnnxConfig
from .tokenization_deberta import DebertaTokenizer
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_deberta_fast import DebertaTokenizerFast
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_deberta import (
DebertaForMaskedLM,
DebertaForQuestionAnswering,
DebertaForSequenceClassification,
DebertaForTokenClassification,
DebertaModel,
DebertaPreTrainedModel,
)
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_deberta import (
TFDebertaForMaskedLM,
TFDebertaForQuestionAnswering,
TFDebertaForSequenceClassification,
TFDebertaForTokenClassification,
TFDebertaModel,
TFDebertaPreTrainedModel,
)
from .configuration_deberta import *
from .modeling_deberta import *
from .modeling_tf_deberta import *
from .tokenization_deberta import *
from .tokenization_deberta_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__)

View File

@@ -194,3 +194,6 @@ class DebertaOnnxConfig(OnnxConfig):
if self._config.type_vocab_size == 0 and "token_type_ids" in dummy_inputs:
del dummy_inputs["token_type_ids"]
return dummy_inputs
__all__ = ["DebertaConfig", "DebertaOnnxConfig"]

View File

@@ -1332,3 +1332,13 @@ class DebertaForQuestionAnswering(DebertaPreTrainedModel):
hidden_states=outputs.hidden_states,
attentions=outputs.attentions,
)
__all__ = [
"DebertaForMaskedLM",
"DebertaForQuestionAnswering",
"DebertaForSequenceClassification",
"DebertaForTokenClassification",
"DebertaModel",
"DebertaPreTrainedModel",
]

View File

@@ -1640,3 +1640,13 @@ class TFDebertaForQuestionAnswering(TFDebertaPreTrainedModel, TFQuestionAnswerin
if getattr(self, "qa_outputs", None) is not None:
with tf.name_scope(self.qa_outputs.name):
self.qa_outputs.build([None, None, self.config.hidden_size])
__all__ = [
"TFDebertaForMaskedLM",
"TFDebertaForQuestionAnswering",
"TFDebertaForSequenceClassification",
"TFDebertaForTokenClassification",
"TFDebertaModel",
"TFDebertaPreTrainedModel",
]

View File

@@ -391,3 +391,6 @@ class DebertaTokenizer(PreTrainedTokenizer):
if (is_split_into_words or add_prefix_space) and (len(text) > 0 and not text[0].isspace()):
text = " " + text
return (text, kwargs)
__all__ = ["DebertaTokenizer"]

View File

@@ -245,3 +245,6 @@ class DebertaTokenizerFast(PreTrainedTokenizerFast):
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__ = ["DebertaTokenizerFast"]

View File

@@ -1,4 +1,4 @@
# Copyright 2020 The HuggingFace Team. All rights reserved.
# Copyright 2024 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,112 +11,20 @@
# 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_tf_available,
is_tokenizers_available,
is_torch_available,
)
_import_structure = {
"configuration_deberta_v2": ["DebertaV2Config", "DebertaV2OnnxConfig"],
"tokenization_deberta_v2": ["DebertaV2Tokenizer"],
}
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["tokenization_deberta_v2_fast"] = ["DebertaV2TokenizerFast"]
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_tf_deberta_v2"] = [
"TFDebertaV2ForMaskedLM",
"TFDebertaV2ForQuestionAnswering",
"TFDebertaV2ForMultipleChoice",
"TFDebertaV2ForSequenceClassification",
"TFDebertaV2ForTokenClassification",
"TFDebertaV2Model",
"TFDebertaV2PreTrainedModel",
]
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_deberta_v2"] = [
"DebertaV2ForMaskedLM",
"DebertaV2ForMultipleChoice",
"DebertaV2ForQuestionAnswering",
"DebertaV2ForSequenceClassification",
"DebertaV2ForTokenClassification",
"DebertaV2Model",
"DebertaV2PreTrainedModel",
]
from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure
if TYPE_CHECKING:
from .configuration_deberta_v2 import (
DebertaV2Config,
DebertaV2OnnxConfig,
)
from .tokenization_deberta_v2 import DebertaV2Tokenizer
try:
if not is_tokenizers_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .tokenization_deberta_v2_fast import DebertaV2TokenizerFast
try:
if not is_tf_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_tf_deberta_v2 import (
TFDebertaV2ForMaskedLM,
TFDebertaV2ForMultipleChoice,
TFDebertaV2ForQuestionAnswering,
TFDebertaV2ForSequenceClassification,
TFDebertaV2ForTokenClassification,
TFDebertaV2Model,
TFDebertaV2PreTrainedModel,
)
try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_deberta_v2 import (
DebertaV2ForMaskedLM,
DebertaV2ForMultipleChoice,
DebertaV2ForQuestionAnswering,
DebertaV2ForSequenceClassification,
DebertaV2ForTokenClassification,
DebertaV2Model,
DebertaV2PreTrainedModel,
)
from .configuration_deberta_v2 import *
from .modeling_deberta_v2 import *
from .modeling_tf_deberta_v2 import *
from .tokenization_deberta_v2 import *
from .tokenization_deberta_v2_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__)

View File

@@ -193,3 +193,6 @@ class DebertaV2OnnxConfig(OnnxConfig):
if self._config.type_vocab_size == 0 and "token_type_ids" in dummy_inputs:
del dummy_inputs["token_type_ids"]
return dummy_inputs
__all__ = ["DebertaV2Config", "DebertaV2OnnxConfig"]

View File

@@ -1506,3 +1506,14 @@ class DebertaV2ForMultipleChoice(DebertaV2PreTrainedModel):
hidden_states=outputs.hidden_states,
attentions=outputs.attentions,
)
__all__ = [
"DebertaV2ForMaskedLM",
"DebertaV2ForMultipleChoice",
"DebertaV2ForQuestionAnswering",
"DebertaV2ForSequenceClassification",
"DebertaV2ForTokenClassification",
"DebertaV2Model",
"DebertaV2PreTrainedModel",
]

Some files were not shown because too many files have changed in this diff Show More