


"""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    ):
       """simple docstring"""


       @slow
       def 	lowercase__							(						self						):






         """simple docstring"""





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

           lowerCAmelCase					:					int								=							TFAutoModel.from_pretrained(snake_case__		,					from_pt=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

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

       @slow
       def 	lowercase__							(						self						):






         """simple docstring"""





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

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

           lowerCAmelCase					:					str								=							AutoModelForPreTraining.from_pretrained(snake_case__		,					from_tf=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

       @slow
       def 	lowercase__							(						self						):






         """simple docstring"""





         for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           lowerCAmelCase					:					str								=							AutoConfig.from_pretrained(snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

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

           lowerCAmelCase					:					Dict								=							AutoModelForCausalLM.from_pretrained(snake_case__		,					from_tf=snake_case__						)
           lowerCAmelCase						,  lowerCAmelCase					:					str								=							AutoModelForCausalLM.from_pretrained(
               snake_case__		,					output_loading_info=snake_case__		,					from_tf=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

       @slow
       def 	lowercase__							(						self						):






         """simple docstring"""





         for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           lowerCAmelCase					:					Union[str, Any]								=							AutoConfig.from_pretrained(snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

           lowerCAmelCase					:					List[Any]								=							TFAutoModelWithLMHead.from_pretrained(snake_case__		,					from_pt=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

           lowerCAmelCase					:					Union[str, Any]								=							AutoModelWithLMHead.from_pretrained(snake_case__		,					from_tf=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

       @slow
       def 	lowercase__							(						self						):






         """simple docstring"""





         for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           lowerCAmelCase					:					Any								=							AutoConfig.from_pretrained(snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

           lowerCAmelCase					:					Dict								=							TFAutoModelForMaskedLM.from_pretrained(snake_case__		,					from_pt=snake_case__						)
           lowerCAmelCase						,  lowerCAmelCase					:					List[Any]								=							TFAutoModelForMaskedLM.from_pretrained(
               snake_case__		,					output_loading_info=snake_case__		,					from_pt=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

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

       @slow
       def 	lowercase__							(						self						):






         """simple docstring"""





         for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           lowerCAmelCase					:					Union[str, Any]								=							AutoConfig.from_pretrained(snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

           lowerCAmelCase					:					List[Any]								=							TFAutoModelForSeqaSeqLM.from_pretrained(snake_case__		,					from_pt=snake_case__						)
           lowerCAmelCase						,  lowerCAmelCase					:					Union[str, Any]								=							TFAutoModelForSeqaSeqLM.from_pretrained(
               snake_case__		,					output_loading_info=snake_case__		,					from_pt=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

           lowerCAmelCase					:					Any								=							AutoModelForSeqaSeqLM.from_pretrained(snake_case__		,					from_tf=snake_case__						)
           lowerCAmelCase						,  lowerCAmelCase					:					Any								=							AutoModelForSeqaSeqLM.from_pretrained(
               snake_case__		,					output_loading_info=snake_case__		,					from_tf=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

       @slow
       def 	lowercase__							(						self						):






         """simple docstring"""





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

           lowerCAmelCase					:					List[Any]								=							TFAutoModelForSequenceClassification.from_pretrained(snake_case__		,					from_pt=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

           lowerCAmelCase					:					Any								=							AutoModelForSequenceClassification.from_pretrained(snake_case__		,					from_tf=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

       @slow
       def 	lowercase__							(						self						):






         """simple docstring"""





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

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

           lowerCAmelCase					:					List[Any]								=							AutoModelForQuestionAnswering.from_pretrained(snake_case__		,					from_tf=snake_case__						)
           self.assertIsNotNone(snake_case__						)
           self.assertIsInstance(snake_case__		,					snake_case__						)

       def 	lowercase__							(						self						):






         """simple docstring"""





         lowerCAmelCase					:					List[str]								=							TFAutoModelWithLMHead.from_pretrained(snake_case__		,					from_pt=snake_case__						)
         self.assertIsInstance(snake_case__		,					snake_case__						)
         self.assertEqual(model.num_parameters()		,					14_410						)
         self.assertEqual(model.num_parameters(only_trainable=snake_case__						)		,					14_410						)

         lowerCAmelCase					:					str								=							AutoModelWithLMHead.from_pretrained(snake_case__		,					from_tf=snake_case__						)
         self.assertIsInstance(snake_case__		,					snake_case__						)
         self.assertEqual(model.num_parameters()		,					14_410						)
         self.assertEqual(model.num_parameters(only_trainable=snake_case__						)		,					14_410						)







       def 	lowercase__							(						self						):






         """simple docstring"""





         lowerCAmelCase					:					Any								=							TFAutoModelWithLMHead.from_pretrained(snake_case__		,					from_pt=snake_case__						)
         self.assertIsInstance(snake_case__		,					snake_case__						)
         self.assertEqual(model.num_parameters()		,					14_410						)
         self.assertEqual(model.num_parameters(only_trainable=snake_case__						)		,					14_410						)

         lowerCAmelCase					:					Dict								=							AutoModelWithLMHead.from_pretrained(snake_case__		,					from_tf=snake_case__						)
         self.assertIsInstance(snake_case__		,					snake_case__						)
         self.assertEqual(model.num_parameters()		,					14_410						)
         self.assertEqual(model.num_parameters(only_trainable=snake_case__						)		,					14_410						)









"""simple docstring"""







import baseaa
def  a__      (    SCREAMING_SNAKE_CASE   :   str    ):


  '''simple docstring'''







  return baseaa.baaencode(string.encode("utf-8"    )    )
def  a__      (    SCREAMING_SNAKE_CASE   :   bytes    ):


  '''simple docstring'''







  return baseaa.baadecode(SCREAMING_SNAKE_CASE    ).decode("utf-8"    )


if __name__ == "__main__":
     lowerCAmelCase__				    =       '''Hello World!'''
     lowerCAmelCase__				    =       baseaa_encode(test)
     print(encoded)

     lowerCAmelCase__				    =       baseaa_decode(encoded)
     print(decoded)





