



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       __lowerCAmelCase   (      unittest.TestCase						):



			@slow
			def    _lowerCamelCase	(						self       :  Optional[int])       ->   Any:



						"""simple docstring"""






						for model_name in ["bert-base-uncased"]:
									_UpperCAmelCase			=       AutoConfig.from_pretrained(_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       TFAutoModel.from_pretrained(_a			,		from_pt=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       AutoModel.from_pretrained(_a			,		from_tf=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)



			@slow
			def    _lowerCamelCase	(						self       :  Optional[Any])       ->   List[Any]:



						"""simple docstring"""






						for model_name in ["bert-base-uncased"]:
									_UpperCAmelCase			=       AutoConfig.from_pretrained(_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       TFAutoModelForPreTraining.from_pretrained(_a			,		from_pt=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       AutoModelForPreTraining.from_pretrained(_a			,		from_tf=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)



			@slow
			def    _lowerCamelCase	(						self       :  Dict)       ->   str:



						"""simple docstring"""






						for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									_UpperCAmelCase			=       AutoConfig.from_pretrained(_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       TFAutoModelForCausalLM.from_pretrained(_a			,		from_pt=_a)
									_UpperCAmelCase	,					_UpperCAmelCase			=       TFAutoModelForCausalLM.from_pretrained(
									    _a			,		output_loading_info=_a			,		from_pt=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       AutoModelForCausalLM.from_pretrained(_a			,		from_tf=_a)
									_UpperCAmelCase	,					_UpperCAmelCase			=       AutoModelForCausalLM.from_pretrained(
									    _a			,		output_loading_info=_a			,		from_tf=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)



			@slow
			def    _lowerCamelCase	(						self       :  int)       ->   Dict:



						"""simple docstring"""






						for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									_UpperCAmelCase			=       AutoConfig.from_pretrained(_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       TFAutoModelWithLMHead.from_pretrained(_a			,		from_pt=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       AutoModelWithLMHead.from_pretrained(_a			,		from_tf=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)



			@slow
			def    _lowerCamelCase	(						self       :  Optional[int])       ->   Any:



						"""simple docstring"""






						for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									_UpperCAmelCase			=       AutoConfig.from_pretrained(_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       TFAutoModelForMaskedLM.from_pretrained(_a			,		from_pt=_a)
									_UpperCAmelCase	,					_UpperCAmelCase			=       TFAutoModelForMaskedLM.from_pretrained(
									    _a			,		output_loading_info=_a			,		from_pt=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       AutoModelForMaskedLM.from_pretrained(_a			,		from_tf=_a)
									_UpperCAmelCase	,					_UpperCAmelCase			=       AutoModelForMaskedLM.from_pretrained(
									    _a			,		output_loading_info=_a			,		from_tf=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)



			@slow
			def    _lowerCamelCase	(						self       :  Optional[int])       ->   str:



						"""simple docstring"""






						for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
									_UpperCAmelCase			=       AutoConfig.from_pretrained(_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       TFAutoModelForSeqaSeqLM.from_pretrained(_a			,		from_pt=_a)
									_UpperCAmelCase	,					_UpperCAmelCase			=       TFAutoModelForSeqaSeqLM.from_pretrained(
									    _a			,		output_loading_info=_a			,		from_pt=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       AutoModelForSeqaSeqLM.from_pretrained(_a			,		from_tf=_a)
									_UpperCAmelCase	,					_UpperCAmelCase			=       AutoModelForSeqaSeqLM.from_pretrained(
									    _a			,		output_loading_info=_a			,		from_tf=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)



			@slow
			def    _lowerCamelCase	(						self       :  Any)       ->   Any:



						"""simple docstring"""






						for model_name in ["bert-base-uncased"]:
									_UpperCAmelCase			=       AutoConfig.from_pretrained(_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       TFAutoModelForSequenceClassification.from_pretrained(_a			,		from_pt=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       AutoModelForSequenceClassification.from_pretrained(_a			,		from_tf=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)



			@slow
			def    _lowerCamelCase	(						self       :  Dict)       ->   Any:



						"""simple docstring"""






						for model_name in ["bert-base-uncased"]:
									_UpperCAmelCase			=       AutoConfig.from_pretrained(_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       TFAutoModelForQuestionAnswering.from_pretrained(_a			,		from_pt=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)

									_UpperCAmelCase			=       AutoModelForQuestionAnswering.from_pretrained(_a			,		from_tf=_a)
									self.assertIsNotNone(_a)
									self.assertIsInstance(_a			,		_a)



			def    _lowerCamelCase	(						self       :  Dict)       ->   str:



						"""simple docstring"""






						_UpperCAmelCase			=       TFAutoModelWithLMHead.from_pretrained(_a			,		from_pt=_a)
						self.assertIsInstance(_a			,		_a)
						self.assertEqual(model.num_parameters()			,		1_44_10)
						self.assertEqual(model.num_parameters(only_trainable=_a)			,		1_44_10)

						_UpperCAmelCase			=       AutoModelWithLMHead.from_pretrained(_a			,		from_tf=_a)
						self.assertIsInstance(_a			,		_a)
						self.assertEqual(model.num_parameters()			,		1_44_10)
						self.assertEqual(model.num_parameters(only_trainable=_a)			,		1_44_10)



			def    _lowerCamelCase	(						self       :  Any)       ->   List[str]:



						"""simple docstring"""






						_UpperCAmelCase			=       TFAutoModelWithLMHead.from_pretrained(_a			,		from_pt=_a)
						self.assertIsInstance(_a			,		_a)
						self.assertEqual(model.num_parameters()			,		1_44_10)
						self.assertEqual(model.num_parameters(only_trainable=_a)			,		1_44_10)

						_UpperCAmelCase			=       AutoModelWithLMHead.from_pretrained(_a			,		from_tf=_a)
						self.assertIsInstance(_a			,		_a)
						self.assertEqual(model.num_parameters()			,		1_44_10)
						self.assertEqual(model.num_parameters(only_trainable=_a)			,		1_44_10)






from typing import TYPE_CHECKING

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


UpperCAmelCase__       =	{
    "configuration_mega": ["MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP", "MegaConfig", "MegaOnnxConfig"],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							UpperCAmelCase__       =	[
							    "MEGA_PRETRAINED_MODEL_ARCHIVE_LIST",
							    "MegaForCausalLM",
							    "MegaForMaskedLM",
							    "MegaForMultipleChoice",
							    "MegaForQuestionAnswering",
							    "MegaForSequenceClassification",
							    "MegaForTokenClassification",
							    "MegaModel",
							    "MegaPreTrainedModel",
							]

if TYPE_CHECKING:
							from .configuration_mega import MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP, MegaConfig, MegaOnnxConfig

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_mega import (
														    MEGA_PRETRAINED_MODEL_ARCHIVE_LIST,
														    MegaForCausalLM,
														    MegaForMaskedLM,
														    MegaForMultipleChoice,
														    MegaForQuestionAnswering,
														    MegaForSequenceClassification,
														    MegaForTokenClassification,
														    MegaModel,
														    MegaPreTrainedModel,
														)

else:
							import sys

							UpperCAmelCase__       =	_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
