



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  _lowercase			(       self      :     str):
											# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											for model_name in ["bert-base-uncased"]:
																	A__	:							List[Any]						    = AutoConfig.from_pretrained(_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Optional[Any]						    = TFAutoModel.from_pretrained(_A			,		from_pt=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Dict						    = AutoModel.from_pretrained(_A			,		from_tf=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)







					@slow
					def  _lowercase			(       self      :     str):
											# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											for model_name in ["bert-base-uncased"]:
																	A__	:							str						    = AutoConfig.from_pretrained(_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Union[str, Any]						    = TFAutoModelForPreTraining.from_pretrained(_A			,		from_pt=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							int						    = AutoModelForPreTraining.from_pretrained(_A			,		from_tf=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)







					@slow
					def  _lowercase			(       self      :     Tuple):
											for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	A__	:							str						    = AutoConfig.from_pretrained(_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Union[str, Any]						    = TFAutoModelForCausalLM.from_pretrained(_A			,		from_pt=_A)
																	A__    ,       A__	:							List[Any]						    = TFAutoModelForCausalLM.from_pretrained(
																	    _A			,		output_loading_info=_A			,		from_pt=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Tuple						    = AutoModelForCausalLM.from_pretrained(_A			,		from_tf=_A)
																	A__    ,       A__	:							Union[str, Any]						    = AutoModelForCausalLM.from_pretrained(
																	    _A			,		output_loading_info=_A			,		from_tf=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)







					@slow
					def  _lowercase			(       self      :     Tuple):
											for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	A__	:							Optional[int]						    = AutoConfig.from_pretrained(_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Any						    = TFAutoModelWithLMHead.from_pretrained(_A			,		from_pt=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							List[Any]						    = AutoModelWithLMHead.from_pretrained(_A			,		from_tf=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)







					@slow
					def  _lowercase			(       self      :     List[str]):
											for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	A__	:							Optional[int]						    = AutoConfig.from_pretrained(_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Union[str, Any]						    = TFAutoModelForMaskedLM.from_pretrained(_A			,		from_pt=_A)
																	A__    ,       A__	:							Any						    = TFAutoModelForMaskedLM.from_pretrained(
																	    _A			,		output_loading_info=_A			,		from_pt=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Any						    = AutoModelForMaskedLM.from_pretrained(_A			,		from_tf=_A)
																	A__    ,       A__	:							Dict						    = AutoModelForMaskedLM.from_pretrained(
																	    _A			,		output_loading_info=_A			,		from_tf=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)







					@slow
					def  _lowercase			(       self      :     List[Any]):
											for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																	A__	:							str						    = AutoConfig.from_pretrained(_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Tuple						    = TFAutoModelForSeqaSeqLM.from_pretrained(_A			,		from_pt=_A)
																	A__    ,       A__	:							str						    = TFAutoModelForSeqaSeqLM.from_pretrained(
																	    _A			,		output_loading_info=_A			,		from_pt=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Optional[int]						    = AutoModelForSeqaSeqLM.from_pretrained(_A			,		from_tf=_A)
																	A__    ,       A__	:							int						    = AutoModelForSeqaSeqLM.from_pretrained(
																	    _A			,		output_loading_info=_A			,		from_tf=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)







					@slow
					def  _lowercase			(       self      :     str):
											# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											for model_name in ["bert-base-uncased"]:
																	A__	:							Dict						    = AutoConfig.from_pretrained(_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Any						    = TFAutoModelForSequenceClassification.from_pretrained(_A			,		from_pt=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							List[Any]						    = AutoModelForSequenceClassification.from_pretrained(_A			,		from_tf=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)







					@slow
					def  _lowercase			(       self      :     Dict):
											# for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											for model_name in ["bert-base-uncased"]:
																	A__	:							Optional[int]						    = AutoConfig.from_pretrained(_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Optional[int]						    = TFAutoModelForQuestionAnswering.from_pretrained(_A			,		from_pt=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)

																	A__	:							Tuple						    = AutoModelForQuestionAnswering.from_pretrained(_A			,		from_tf=_A)
																	self.assertIsNotNone(_A)
																	self.assertIsInstance(_A			,		_A)







					def  _lowercase			(       self      :     List[Any]):
											A__	:							Optional[Any]						    = TFAutoModelWithLMHead.from_pretrained(_A			,		from_pt=_A)
											self.assertIsInstance(_A			,		_A)
											self.assertEqual(model.num_parameters()			,		1_4410)
											self.assertEqual(model.num_parameters(only_trainable=_A)			,		1_4410)

											A__	:							Any						    = AutoModelWithLMHead.from_pretrained(_A			,		from_tf=_A)
											self.assertIsInstance(_A			,		_A)
											self.assertEqual(model.num_parameters()			,		1_4410)
											self.assertEqual(model.num_parameters(only_trainable=_A)			,		1_4410)







					def  _lowercase			(       self      :     List[Any]):
											A__	:							List[Any]						    = TFAutoModelWithLMHead.from_pretrained(_A			,		from_pt=_A)
											self.assertIsInstance(_A			,		_A)
											self.assertEqual(model.num_parameters()			,		1_4410)
											self.assertEqual(model.num_parameters(only_trainable=_A)			,		1_4410)

											A__	:							int						    = AutoModelWithLMHead.from_pretrained(_A			,		from_tf=_A)
											self.assertIsInstance(_A			,		_A)
											self.assertEqual(model.num_parameters()			,		1_4410)
											self.assertEqual(model.num_parameters(only_trainable=_A)			,		1_4410)




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


snake_case    :						str  =						{
    'configuration_albert': ['ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AlbertConfig', 'AlbertOnnxConfig'],
}

try:
		if not is_sentencepiece_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						Any  =						['AlbertTokenizer']

try:
		if not is_tokenizers_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						List[str]  =						['AlbertTokenizerFast']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						List[str]  =						[
		    'ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'AlbertForMaskedLM',
		    'AlbertForMultipleChoice',
		    'AlbertForPreTraining',
		    'AlbertForQuestionAnswering',
		    'AlbertForSequenceClassification',
		    'AlbertForTokenClassification',
		    'AlbertModel',
		    'AlbertPreTrainedModel',
		    'load_tf_weights_in_albert',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						Union[str, Any]  =						[
		    'TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'TFAlbertForMaskedLM',
		    'TFAlbertForMultipleChoice',
		    'TFAlbertForPreTraining',
		    'TFAlbertForQuestionAnswering',
		    'TFAlbertForSequenceClassification',
		    'TFAlbertForTokenClassification',
		    'TFAlbertMainLayer',
		    'TFAlbertModel',
		    'TFAlbertPreTrainedModel',
		]

try:
		if not is_flax_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		snake_case    :						Any  =						[
		    'FlaxAlbertForMaskedLM',
		    'FlaxAlbertForMultipleChoice',
		    'FlaxAlbertForPreTraining',
		    'FlaxAlbertForQuestionAnswering',
		    'FlaxAlbertForSequenceClassification',
		    'FlaxAlbertForTokenClassification',
		    'FlaxAlbertModel',
		    'FlaxAlbertPreTrainedModel',
		]

if TYPE_CHECKING:
		from .configuration_albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig, AlbertOnnxConfig

		try:
				if not is_sentencepiece_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_albert import AlbertTokenizer

		try:
				if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_albert_fast import AlbertTokenizerFast

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_albert import (
				    ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    AlbertForMaskedLM,
				    AlbertForMultipleChoice,
				    AlbertForPreTraining,
				    AlbertForQuestionAnswering,
				    AlbertForSequenceClassification,
				    AlbertForTokenClassification,
				    AlbertModel,
				    AlbertPreTrainedModel,
				    load_tf_weights_in_albert,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_albert import (
				    TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFAlbertForMaskedLM,
				    TFAlbertForMultipleChoice,
				    TFAlbertForPreTraining,
				    TFAlbertForQuestionAnswering,
				    TFAlbertForSequenceClassification,
				    TFAlbertForTokenClassification,
				    TFAlbertMainLayer,
				    TFAlbertModel,
				    TFAlbertPreTrainedModel,
				)

		try:
				if not is_flax_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_flax_albert import (
				    FlaxAlbertForMaskedLM,
				    FlaxAlbertForMultipleChoice,
				    FlaxAlbertForPreTraining,
				    FlaxAlbertForQuestionAnswering,
				    FlaxAlbertForSequenceClassification,
				    FlaxAlbertForTokenClassification,
				    FlaxAlbertModel,
				    FlaxAlbertPreTrainedModel,
				)
else:
		import sys

		snake_case    :						Any  =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)