




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





						@slow
						def       __UpperCamelCase     (							self      :	int)						->       Any:




											"""simple docstring"""







											for model_name in ["bert-base-uncased"]:
																_lowerCAmelCase:List[Any]									=  AutoConfig.from_pretrained(a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Optional[int]									=  TFAutoModel.from_pretrained(a__     ,from_pt=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:List[Any]									=  AutoModel.from_pretrained(a__     ,from_tf=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)





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




											"""simple docstring"""







											for model_name in ["bert-base-uncased"]:
																_lowerCAmelCase:Optional[Any]									=  AutoConfig.from_pretrained(a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:List[Any]									=  TFAutoModelForPreTraining.from_pretrained(a__     ,from_pt=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Optional[int]									=  AutoModelForPreTraining.from_pretrained(a__     ,from_tf=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)





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




											"""simple docstring"""







											for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																_lowerCAmelCase:Dict									=  AutoConfig.from_pretrained(a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Union[str, Any]									=  TFAutoModelForCausalLM.from_pretrained(a__     ,from_pt=a__)
																_lowerCAmelCase							,   _lowerCAmelCase:Any									=  TFAutoModelForCausalLM.from_pretrained(
																    a__     ,output_loading_info=a__     ,from_pt=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Union[str, Any]									=  AutoModelForCausalLM.from_pretrained(a__     ,from_tf=a__)
																_lowerCAmelCase							,   _lowerCAmelCase:Any									=  AutoModelForCausalLM.from_pretrained(
																    a__     ,output_loading_info=a__     ,from_tf=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)





						@slow
						def       __UpperCamelCase     (							self      :	List[str])						->       Any:




											"""simple docstring"""







											for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																_lowerCAmelCase:Optional[int]									=  AutoConfig.from_pretrained(a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Optional[Any]									=  TFAutoModelWithLMHead.from_pretrained(a__     ,from_pt=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Tuple									=  AutoModelWithLMHead.from_pretrained(a__     ,from_tf=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)





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




											"""simple docstring"""







											for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																_lowerCAmelCase:str									=  AutoConfig.from_pretrained(a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:int									=  TFAutoModelForMaskedLM.from_pretrained(a__     ,from_pt=a__)
																_lowerCAmelCase							,   _lowerCAmelCase:Optional[Any]									=  TFAutoModelForMaskedLM.from_pretrained(
																    a__     ,output_loading_info=a__     ,from_pt=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Optional[int]									=  AutoModelForMaskedLM.from_pretrained(a__     ,from_tf=a__)
																_lowerCAmelCase							,   _lowerCAmelCase:Union[str, Any]									=  AutoModelForMaskedLM.from_pretrained(
																    a__     ,output_loading_info=a__     ,from_tf=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)





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




											"""simple docstring"""







											for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																_lowerCAmelCase:Optional[int]									=  AutoConfig.from_pretrained(a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:int									=  TFAutoModelForSeqaSeqLM.from_pretrained(a__     ,from_pt=a__)
																_lowerCAmelCase							,   _lowerCAmelCase:Optional[Any]									=  TFAutoModelForSeqaSeqLM.from_pretrained(
																    a__     ,output_loading_info=a__     ,from_pt=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Any									=  AutoModelForSeqaSeqLM.from_pretrained(a__     ,from_tf=a__)
																_lowerCAmelCase							,   _lowerCAmelCase:Optional[Any]									=  AutoModelForSeqaSeqLM.from_pretrained(
																    a__     ,output_loading_info=a__     ,from_tf=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)





						@slow
						def       __UpperCamelCase     (							self      :	Union[str, Any])						->       Union[str, Any]:




											"""simple docstring"""







											for model_name in ["bert-base-uncased"]:
																_lowerCAmelCase:Optional[int]									=  AutoConfig.from_pretrained(a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Union[str, Any]									=  TFAutoModelForSequenceClassification.from_pretrained(a__     ,from_pt=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

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





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




											"""simple docstring"""







											for model_name in ["bert-base-uncased"]:
																_lowerCAmelCase:Union[str, Any]									=  AutoConfig.from_pretrained(a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:Dict									=  TFAutoModelForQuestionAnswering.from_pretrained(a__     ,from_pt=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)

																_lowerCAmelCase:str									=  AutoModelForQuestionAnswering.from_pretrained(a__     ,from_tf=a__)
																self.assertIsNotNone(a__)
																self.assertIsInstance(a__     ,a__)





						def       __UpperCamelCase     (							self      :	Tuple)						->       Dict:




											"""simple docstring"""







											_lowerCAmelCase:Dict									=  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)

											_lowerCAmelCase:Optional[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       __UpperCamelCase     (							self      :	str)						->       Optional[int]:




											"""simple docstring"""







											_lowerCAmelCase: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)

											_lowerCAmelCase:Optional[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)












"""simple docstring"""






import baseaa





def 							UpperCAmelCase		(		snake_case			:					str    ):
					return baseaa.aaaencode(string.encode('''utf-8'''    )    )





def 							UpperCAmelCase		(		snake_case			:					bytes    ):
					return baseaa.aaadecode(snake_case    ).decode('''utf-8'''    )


if __name__ == "__main__":
				import doctest

				doctest.testmod()






