



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







       '''simple docstring'''


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


             '''simple docstring'''




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

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

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



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


             '''simple docstring'''




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

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

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



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


             '''simple docstring'''




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

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

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



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


             '''simple docstring'''




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

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

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



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


             '''simple docstring'''




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

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

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



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


             '''simple docstring'''




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

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

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



       @slow
       def 					lowercase__    (							self      :  int   )			->						List[str]:


             '''simple docstring'''




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

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

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



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


             '''simple docstring'''




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

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

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



       def 					lowercase__    (							self      :  Tuple   )			->						List[Any]:


             '''simple docstring'''




             UpperCAmelCase_      			=							TFAutoModelWithLMHead.from_pretrained(_UpperCAmelCase		,    from_pt=_UpperCAmelCase   )
             self.assertIsInstance(_UpperCAmelCase		,    _UpperCAmelCase   )
             self.assertEqual(model.num_parameters()		,    14410   )
             self.assertEqual(model.num_parameters(only_trainable=_UpperCAmelCase   )		,    14410   )

             UpperCAmelCase_      			=							AutoModelWithLMHead.from_pretrained(_UpperCAmelCase		,    from_tf=_UpperCAmelCase   )
             self.assertIsInstance(_UpperCAmelCase		,    _UpperCAmelCase   )
             self.assertEqual(model.num_parameters()		,    14410   )
             self.assertEqual(model.num_parameters(only_trainable=_UpperCAmelCase   )		,    14410   )







       def 					lowercase__    (							self      :  Union[str, Any]   )			->						Optional[Any]:


             '''simple docstring'''




             UpperCAmelCase_      			=							TFAutoModelWithLMHead.from_pretrained(_UpperCAmelCase		,    from_pt=_UpperCAmelCase   )
             self.assertIsInstance(_UpperCAmelCase		,    _UpperCAmelCase   )
             self.assertEqual(model.num_parameters()		,    14410   )
             self.assertEqual(model.num_parameters(only_trainable=_UpperCAmelCase   )		,    14410   )

             UpperCAmelCase_      			=							AutoModelWithLMHead.from_pretrained(_UpperCAmelCase		,    from_tf=_UpperCAmelCase   )
             self.assertIsInstance(_UpperCAmelCase		,    _UpperCAmelCase   )
             self.assertEqual(model.num_parameters()		,    14410   )
             self.assertEqual(model.num_parameters(only_trainable=_UpperCAmelCase   )		,    14410   )









"""simple docstring"""





from .configuration_bert_masked import MaskedBertConfig
from .modeling_bert_masked import (
    MaskedBertForMultipleChoice,
    MaskedBertForQuestionAnswering,
    MaskedBertForSequenceClassification,
    MaskedBertForTokenClassification,
    MaskedBertModel,
)
from .modules import *




