






'''simple docstring'''







from __future__ import annotations

import unittest

from transformers import is_tf_available, is_torch_available
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow


if is_tf_available():
		from transformers import (
		    AutoConfig,
		    BertConfig,
		    GPTaConfig,
		    TaConfig,
		    TFAutoModel,
		    TFAutoModelForCausalLM,
		    TFAutoModelForMaskedLM,
		    TFAutoModelForPreTraining,
		    TFAutoModelForQuestionAnswering,
		    TFAutoModelForSeqaSeqLM,
		    TFAutoModelForSequenceClassification,
		    TFAutoModelWithLMHead,
		    TFBertForMaskedLM,
		    TFBertForPreTraining,
		    TFBertForQuestionAnswering,
		    TFBertForSequenceClassification,
		    TFBertModel,
		    TFGPTaLMHeadModel,
		    TFRobertaForMaskedLM,
		    TFTaForConditionalGeneration,
		)
		from transformers.models.bert.modeling_tf_bert import TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST
		from transformers.models.gpta.modeling_tf_gpta import TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST
		from transformers.models.ta.modeling_tf_ta import TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST

if is_torch_available():
		from transformers import (
		    AutoModel,
		    AutoModelForCausalLM,
		    AutoModelForMaskedLM,
		    AutoModelForPreTraining,
		    AutoModelForQuestionAnswering,
		    AutoModelForSeqaSeqLM,
		    AutoModelForSequenceClassification,
		    AutoModelWithLMHead,
		    BertForMaskedLM,
		    BertForPreTraining,
		    BertForQuestionAnswering,
		    BertForSequenceClassification,
		    BertModel,
		    GPTaLMHeadModel,
		    RobertaForMaskedLM,
		    TaForConditionalGeneration,
		)





@is_pt_tf_cross_test
class 						SCREAMING_SNAKE_CASE       (       unittest.TestCase							):






			@slow
			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[Any]       )      ->      Union[str, Any]:
							# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							for model_name in ["bert-base-uncased"]:
											a_		:	List[Any]									=   AutoConfig.from_pretrained(__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Tuple									=   TFAutoModel.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Union[str, Any]									=   AutoModel.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )






			@slow
			def       SCREAMING_SNAKE_CASE   (			self   :      List[Any]       )      ->      Optional[int]:
							# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							for model_name in ["bert-base-uncased"]:
											a_		:	Any									=   AutoConfig.from_pretrained(__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	int									=   TFAutoModelForPreTraining.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Optional[Any]									=   AutoModelForPreTraining.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )






			@slow
			def       SCREAMING_SNAKE_CASE   (			self   :      Union[str, Any]       )      ->      List[str]:
							for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											a_		:	Optional[int]									=   AutoConfig.from_pretrained(__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	int									=   TFAutoModelForCausalLM.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											a_					,      a_		:	str									=   TFAutoModelForCausalLM.from_pretrained(
											    __SCREAMING_SNAKE_CASE	,    output_loading_info=__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Optional[Any]									=   AutoModelForCausalLM.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											a_					,      a_		:	Union[str, Any]									=   AutoModelForCausalLM.from_pretrained(
											    __SCREAMING_SNAKE_CASE	,    output_loading_info=__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )






			@slow
			def       SCREAMING_SNAKE_CASE   (			self   :      Tuple       )      ->      List[Any]:
							for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											a_		:	List[str]									=   AutoConfig.from_pretrained(__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	List[str]									=   TFAutoModelWithLMHead.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	List[str]									=   AutoModelWithLMHead.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )






			@slow
			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[int]       )      ->      Optional[Any]:
							for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											a_		:	Tuple									=   AutoConfig.from_pretrained(__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	List[Any]									=   TFAutoModelForMaskedLM.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											a_					,      a_		:	Optional[Any]									=   TFAutoModelForMaskedLM.from_pretrained(
											    __SCREAMING_SNAKE_CASE	,    output_loading_info=__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Dict									=   AutoModelForMaskedLM.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											a_					,      a_		:	Optional[Any]									=   AutoModelForMaskedLM.from_pretrained(
											    __SCREAMING_SNAKE_CASE	,    output_loading_info=__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )






			@slow
			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[Any]       )      ->      Tuple:
							for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											a_		:	Tuple									=   AutoConfig.from_pretrained(__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Dict									=   TFAutoModelForSeqaSeqLM.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											a_					,      a_		:	Dict									=   TFAutoModelForSeqaSeqLM.from_pretrained(
											    __SCREAMING_SNAKE_CASE	,    output_loading_info=__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Any									=   AutoModelForSeqaSeqLM.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											a_					,      a_		:	Tuple									=   AutoModelForSeqaSeqLM.from_pretrained(
											    __SCREAMING_SNAKE_CASE	,    output_loading_info=__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )






			@slow
			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[Any]       )      ->      Tuple:
							# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							for model_name in ["bert-base-uncased"]:
											a_		:	Optional[Any]									=   AutoConfig.from_pretrained(__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Dict									=   TFAutoModelForSequenceClassification.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	List[str]									=   AutoModelForSequenceClassification.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )






			@slow
			def       SCREAMING_SNAKE_CASE   (			self   :      Union[str, Any]       )      ->      Tuple:
							# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
							for model_name in ["bert-base-uncased"]:
											a_		:	List[str]									=   AutoConfig.from_pretrained(__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	str									=   TFAutoModelForQuestionAnswering.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

											a_		:	Union[str, Any]									=   AutoModelForQuestionAnswering.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
											self.assertIsNotNone(__SCREAMING_SNAKE_CASE       )
											self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )






			def       SCREAMING_SNAKE_CASE   (			self   :      str       )      ->      Union[str, Any]:
							a_		:	Union[str, Any]									=   TFAutoModelWithLMHead.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
							self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )
							self.assertEqual(model.num_parameters()	,    1_4410       )
							self.assertEqual(model.num_parameters(only_trainable=__SCREAMING_SNAKE_CASE       )	,    1_4410       )

							a_		:	Dict									=   AutoModelWithLMHead.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
							self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )
							self.assertEqual(model.num_parameters()	,    1_4410       )
							self.assertEqual(model.num_parameters(only_trainable=__SCREAMING_SNAKE_CASE       )	,    1_4410       )







			def       SCREAMING_SNAKE_CASE   (			self   :      Any       )      ->      Dict:
							a_		:	Optional[int]									=   TFAutoModelWithLMHead.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_pt=__SCREAMING_SNAKE_CASE       )
							self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )
							self.assertEqual(model.num_parameters()	,    1_4410       )
							self.assertEqual(model.num_parameters(only_trainable=__SCREAMING_SNAKE_CASE       )	,    1_4410       )

							a_		:	List[str]									=   AutoModelWithLMHead.from_pretrained(__SCREAMING_SNAKE_CASE	,    from_tf=__SCREAMING_SNAKE_CASE       )
							self.assertIsInstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )
							self.assertEqual(model.num_parameters()	,    1_4410       )
							self.assertEqual(model.num_parameters(only_trainable=__SCREAMING_SNAKE_CASE       )	,    1_4410       )












'''simple docstring'''







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


__lowerCAmelCase									=   {'configuration_deit': ['DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DeiTConfig', 'DeiTOnnxConfig']}

try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__lowerCAmelCase									=   ['DeiTFeatureExtractor']
		__lowerCAmelCase									=   ['DeiTImageProcessor']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__lowerCAmelCase									=   [
		    'DEIT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'DeiTForImageClassification',
		    'DeiTForImageClassificationWithTeacher',
		    'DeiTForMaskedImageModeling',
		    'DeiTModel',
		    'DeiTPreTrainedModel',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__lowerCAmelCase									=   [
		    'TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'TFDeiTForImageClassification',
		    'TFDeiTForImageClassificationWithTeacher',
		    'TFDeiTForMaskedImageModeling',
		    'TFDeiTModel',
		    'TFDeiTPreTrainedModel',
		]


if TYPE_CHECKING:
		from .configuration_deit import DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP, DeiTConfig, DeiTOnnxConfig

		try:
				if not is_vision_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_deit import DeiTFeatureExtractor
				from .image_processing_deit import DeiTImageProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_deit import (
				    DEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    DeiTForImageClassification,
				    DeiTForImageClassificationWithTeacher,
				    DeiTForMaskedImageModeling,
				    DeiTModel,
				    DeiTPreTrainedModel,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_deit import (
				    TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFDeiTForImageClassification,
				    TFDeiTForImageClassificationWithTeacher,
				    TFDeiTForMaskedImageModeling,
				    TFDeiTModel,
				    TFDeiTPreTrainedModel,
				)


else:
		import sys

		__lowerCAmelCase									=   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




