





'''simple docstring'''

import os
import tempfile
import unittest

from transformers import DistilBertConfig, is_torch_available
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
   import torch

   from transformers import (
       DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
       DistilBertForMaskedLM,
       DistilBertForMultipleChoice,
       DistilBertForQuestionAnswering,
       DistilBertForSequenceClassification,
       DistilBertForTokenClassification,
       DistilBertModel,
   )





class lowerCamelCase						(__lowerCamelCase					):







  def __init__(		self     ,     lowercase__     ,     lowercase__=13     ,     lowercase__=7     ,     lowercase__=True     ,     lowercase__=True     ,     lowercase__=False     ,     lowercase__=True     ,     lowercase__=99     ,     lowercase__=32     ,     lowercase__=5     ,     lowercase__=4     ,     lowercase__=37     ,     lowercase__="gelu"     ,     lowercase__=0.1     ,     lowercase__=0.1     ,     lowercase__=512     ,     lowercase__=16     ,     lowercase__=2     ,     lowercase__=0.02     ,     lowercase__=3     ,     lowercase__=4     ,     lowercase__=None     ,     )		->						Optional[Any]:






        """simple docstring"""





        _snake_case		:	Tuple					     =     parent
        _snake_case		:	List[Any]					     =     batch_size
        _snake_case		:	Optional[Any]					     =     seq_length
        _snake_case		:	Any					     =     is_training
        _snake_case		:	Any					     =     use_input_mask
        _snake_case		:	Union[str, Any]					     =     use_token_type_ids
        _snake_case		:	Any					     =     use_labels
        _snake_case		:	Tuple					     =     vocab_size
        _snake_case		:	Any					     =     hidden_size
        _snake_case		:	str					     =     num_hidden_layers
        _snake_case		:	Dict					     =     num_attention_heads
        _snake_case		:	List[Any]					     =     intermediate_size
        _snake_case		:	str					     =     hidden_act
        _snake_case		:	str					     =     hidden_dropout_prob
        _snake_case		:	Optional[int]					     =     attention_probs_dropout_prob
        _snake_case		:	Optional[int]					     =     max_position_embeddings
        _snake_case		:	List[str]					     =     type_vocab_size
        _snake_case		:	Union[str, Any]					     =     type_sequence_label_size
        _snake_case		:	Dict					     =     initializer_range
        _snake_case		:	List[Any]					     =     num_labels
        _snake_case		:	Optional[Any]					     =     num_choices
        _snake_case		:	int					     =     scope







  def 				UpperCAmelCase_				(		self		)		->						int:






        """simple docstring"""





        _snake_case		:	Tuple					     =     ids_tensor([self.batch_size, self.seq_length]     ,     self.vocab_size		)

        _snake_case		:	Union[str, Any]					     =     None
        if self.use_input_mask:
              _snake_case		:	Union[str, Any]					     =     random_attention_mask([self.batch_size, self.seq_length]		)

        _snake_case		:	Optional[int]					     =     None
        _snake_case		:	Union[str, Any]					     =     None
        _snake_case		:	Tuple					     =     None
        if self.use_labels:
              _snake_case		:	List[str]					     =     ids_tensor([self.batch_size]     ,     self.type_sequence_label_size		)
              _snake_case		:	Optional[Any]					     =     ids_tensor([self.batch_size, self.seq_length]     ,     self.num_labels		)
              _snake_case		:	str					     =     ids_tensor([self.batch_size]     ,     self.num_choices		)

        _snake_case		:	Tuple					     =     self.get_config()

        return config, input_ids, input_mask, sequence_labels, token_labels, choice_labels







  def 				UpperCAmelCase_				(		self		)		->						Optional[Any]:






        """simple docstring"""





        return DistilBertConfig(
            vocab_size=self.vocab_size     ,     dim=self.hidden_size     ,     n_layers=self.num_hidden_layers     ,     n_heads=self.num_attention_heads     ,     hidden_dim=self.intermediate_size     ,     hidden_act=self.hidden_act     ,     dropout=self.hidden_dropout_prob     ,     attention_dropout=self.attention_probs_dropout_prob     ,     max_position_embeddings=self.max_position_embeddings     ,     initializer_range=self.initializer_range     ,     )







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__		)		->						Optional[int]:






        """simple docstring"""





        _snake_case		:	Optional[Any]					     =     DistilBertModel(config=SCREAMING_SNAKE_CASE_		)
        model.to(SCREAMING_SNAKE_CASE_		)
        model.eval()
        _snake_case		:	str					     =     model(SCREAMING_SNAKE_CASE_     ,     SCREAMING_SNAKE_CASE_		)
        _snake_case		:	int					     =     model(SCREAMING_SNAKE_CASE_		)
        self.parent.assertEqual(result.last_hidden_state.shape     ,     (self.batch_size, self.seq_length, self.hidden_size)		)







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__		)		->						Any:






        """simple docstring"""





        _snake_case		:	List[Any]					     =     DistilBertForMaskedLM(config=SCREAMING_SNAKE_CASE_		)
        model.to(SCREAMING_SNAKE_CASE_		)
        model.eval()
        _snake_case		:	Tuple					     =     model(SCREAMING_SNAKE_CASE_     ,     attention_mask=SCREAMING_SNAKE_CASE_     ,     labels=SCREAMING_SNAKE_CASE_		)
        self.parent.assertEqual(result.logits.shape     ,     (self.batch_size, self.seq_length, self.vocab_size)		)







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__		)		->						List[str]:






        """simple docstring"""





        _snake_case		:	int					     =     DistilBertForQuestionAnswering(config=SCREAMING_SNAKE_CASE_		)
        model.to(SCREAMING_SNAKE_CASE_		)
        model.eval()
        _snake_case		:	Dict					     =     model(
            SCREAMING_SNAKE_CASE_     ,     attention_mask=SCREAMING_SNAKE_CASE_     ,     start_positions=SCREAMING_SNAKE_CASE_     ,     end_positions=SCREAMING_SNAKE_CASE_		)
        self.parent.assertEqual(result.start_logits.shape     ,     (self.batch_size, self.seq_length)		)
        self.parent.assertEqual(result.end_logits.shape     ,     (self.batch_size, self.seq_length)		)







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__		)		->						Tuple:






        """simple docstring"""





        _snake_case		:	Union[str, Any]					     =     self.num_labels
        _snake_case		:	Optional[int]					     =     DistilBertForSequenceClassification(SCREAMING_SNAKE_CASE_		)
        model.to(SCREAMING_SNAKE_CASE_		)
        model.eval()
        _snake_case		:	List[str]					     =     model(SCREAMING_SNAKE_CASE_     ,     attention_mask=SCREAMING_SNAKE_CASE_     ,     labels=SCREAMING_SNAKE_CASE_		)
        self.parent.assertEqual(result.logits.shape     ,     (self.batch_size, self.num_labels)		)







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__		)		->						Dict:






        """simple docstring"""





        _snake_case		:	Union[str, Any]					     =     self.num_labels
        _snake_case		:	Any					     =     DistilBertForTokenClassification(config=SCREAMING_SNAKE_CASE_		)
        model.to(SCREAMING_SNAKE_CASE_		)
        model.eval()

        _snake_case		:	Dict					     =     model(SCREAMING_SNAKE_CASE_     ,     attention_mask=SCREAMING_SNAKE_CASE_     ,     labels=SCREAMING_SNAKE_CASE_		)
        self.parent.assertEqual(result.logits.shape     ,     (self.batch_size, self.seq_length, self.num_labels)		)







  def 				UpperCAmelCase_				(		self     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__     ,     lowercase__		)		->						List[str]:






        """simple docstring"""





        _snake_case		:	List[str]					     =     self.num_choices
        _snake_case		:	Optional[Any]					     =     DistilBertForMultipleChoice(config=SCREAMING_SNAKE_CASE_		)
        model.to(SCREAMING_SNAKE_CASE_		)
        model.eval()
        _snake_case		:	List[str]					     =     input_ids.unsqueeze(1		).expand(-1     ,     self.num_choices     ,     -1		).contiguous()
        _snake_case		:	List[str]					     =     input_mask.unsqueeze(1		).expand(-1     ,     self.num_choices     ,     -1		).contiguous()
        _snake_case		:	Optional[int]					     =     model(
            SCREAMING_SNAKE_CASE_     ,     attention_mask=SCREAMING_SNAKE_CASE_     ,     labels=SCREAMING_SNAKE_CASE_     ,     )
        self.parent.assertEqual(result.logits.shape     ,     (self.batch_size, self.num_choices)		)







  def 				UpperCAmelCase_				(		self		)		->						Optional[int]:






        """simple docstring"""





        _snake_case		:	int					     =     self.prepare_config_and_inputs()
        ((_snake_case)     ,							(_snake_case)     ,							(_snake_case)     ,							(_snake_case)     ,							(_snake_case)     ,							(_snake_case))		:	str					     =     config_and_inputs
        _snake_case		:	Dict					     =     {'''input_ids''': input_ids, '''attention_mask''': input_mask}
        return config, inputs_dict





@require_torch
class lowerCamelCase						(__lowerCamelCase						,      __lowerCamelCase						,      unittest.TestCase					):
  _lowercase  :	Any       					=				(
      (
          DistilBertModel,
          DistilBertForMaskedLM,
          DistilBertForMultipleChoice,
          DistilBertForQuestionAnswering,
          DistilBertForSequenceClassification,
          DistilBertForTokenClassification,
      )
      if is_torch_available()
      else None
  )
  _lowercase  :	Tuple       					=				(
      {
          """feature-extraction""": DistilBertModel,
          """fill-mask""": DistilBertForMaskedLM,
          """question-answering""": DistilBertForQuestionAnswering,
          """text-classification""": DistilBertForSequenceClassification,
          """token-classification""": DistilBertForTokenClassification,
          """zero-shot""": DistilBertForSequenceClassification,
      }
      if is_torch_available()
      else {}
  )
  _lowercase  :	Any       					=				True
  _lowercase  :	List[Any]       					=				True
  _lowercase  :	str       					=				True
  _lowercase  :	List[str]       					=				True







  def 				UpperCAmelCase_				(		self		)		->						str:






        """simple docstring"""





        _snake_case		:	Union[str, Any]					     =     DistilBertModelTester(self		)
        _snake_case		:	Tuple					     =     ConfigTester(self     ,     config_class=SCREAMING_SNAKE_CASE_     ,     dim=37		)







  def 				UpperCAmelCase_				(		self		)		->						int:






        """simple docstring"""





        self.config_tester.run_common_tests()







  def 				UpperCAmelCase_				(		self		)		->						Tuple:






        """simple docstring"""





        _snake_case		:	str					     =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_model(*SCREAMING_SNAKE_CASE_		)







  def 				UpperCAmelCase_				(		self		)		->						Optional[Any]:






        """simple docstring"""





        _snake_case		:	Tuple					     =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_masked_lm(*SCREAMING_SNAKE_CASE_		)







  def 				UpperCAmelCase_				(		self		)		->						int:






        """simple docstring"""





        _snake_case		:	List[str]					     =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_question_answering(*SCREAMING_SNAKE_CASE_		)







  def 				UpperCAmelCase_				(		self		)		->						str:






        """simple docstring"""





        _snake_case		:	Optional[Any]					     =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_sequence_classification(*SCREAMING_SNAKE_CASE_		)







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






        """simple docstring"""





        _snake_case		:	Optional[int]					     =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_token_classification(*SCREAMING_SNAKE_CASE_		)







  def 				UpperCAmelCase_				(		self		)		->						Optional[Any]:






        """simple docstring"""





        _snake_case		:	Tuple					     =     self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_distilbert_for_multiple_choice(*SCREAMING_SNAKE_CASE_		)







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






        """simple docstring"""





        for model_name in DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _snake_case		:	List[str]					     =     DistilBertModel.from_pretrained(SCREAMING_SNAKE_CASE_		)
              self.assertIsNotNone(SCREAMING_SNAKE_CASE_		)







  @slow
  @require_torch_gpu
  def 				UpperCAmelCase_				(		self		)		->						int:






        """simple docstring"""





        _snake_case     ,							_snake_case		:	List[Any]					     =     self.model_tester.prepare_config_and_inputs_for_common()
        for model_class in self.all_model_classes:
              # BertForMultipleChoice behaves incorrectly in JIT environments.
              if model_class == DistilBertForMultipleChoice:
                    return

              _snake_case		:	Union[str, Any]					     =     True
              _snake_case		:	Tuple					     =     model_class(config=SCREAMING_SNAKE_CASE_		)

              _snake_case		:	int					     =     self._prepare_for_class(SCREAMING_SNAKE_CASE_     ,     SCREAMING_SNAKE_CASE_		)
              _snake_case		:	str					     =     torch.jit.trace(
                  SCREAMING_SNAKE_CASE_     ,     (inputs_dict['''input_ids'''].to('''cpu'''		), inputs_dict['''attention_mask'''].to('''cpu'''		))		)

              with tempfile.TemporaryDirectory() as tmp:
                    torch.jit.save(SCREAMING_SNAKE_CASE_     ,     os.path.join(SCREAMING_SNAKE_CASE_     ,     '''traced_model.pt'''		)		)
                    _snake_case		:	int					     =     torch.jit.load(os.path.join(SCREAMING_SNAKE_CASE_     ,     '''traced_model.pt'''		)     ,     map_location=SCREAMING_SNAKE_CASE_		)
                    loaded(inputs_dict['''input_ids'''].to(SCREAMING_SNAKE_CASE_		)     ,     inputs_dict['''attention_mask'''].to(SCREAMING_SNAKE_CASE_		)		)





@require_torch
class lowerCamelCase						(unittest.TestCase					):







  @slow
  def 				UpperCAmelCase_				(		self		)		->						Any:






        """simple docstring"""





        _snake_case		:	Optional[Any]					     =     DistilBertModel.from_pretrained('''distilbert-base-uncased'''		)
        _snake_case		:	List[str]					     =     torch.tensor([[0, 345, 232, 328, 740, 140, 1_695, 69, 6_078, 1_588, 2]]		)
        _snake_case		:	int					     =     torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]		)
        with torch.no_grad():
              _snake_case		:	Union[str, Any]					     =     model(SCREAMING_SNAKE_CASE_     ,     attention_mask=SCREAMING_SNAKE_CASE_		)[0]
        _snake_case		:	str					     =     torch.Size((1, 11, 768)		)
        self.assertEqual(output.shape     ,     SCREAMING_SNAKE_CASE_		)
        _snake_case		:	Union[str, Any]					     =     torch.tensor(
            [[[-0.1_639, 0.3_299, 0.1_648], [-0.1_746, 0.3_289, 0.1_710], [-0.1_884, 0.3_357, 0.1_810]]]		)

        self.assertTrue(torch.allclose(output[:, 1:4, 1:4]     ,     SCREAMING_SNAKE_CASE_     ,     atol=1E-4		)		)









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







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






        """simple docstring"""





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

              _snake_case		:	Any					     =     TFAutoModel.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	str					     =     AutoModel.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)







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






        """simple docstring"""





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

              _snake_case		:	Dict					     =     TFAutoModelForPreTraining.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	Tuple					     =     AutoModelForPreTraining.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)







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






        """simple docstring"""





        for model_name in TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _snake_case		:	Optional[int]					     =     AutoConfig.from_pretrained(lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	List[Any]					     =     TFAutoModelForCausalLM.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
              _snake_case     ,							_snake_case		:	Tuple					     =     TFAutoModelForCausalLM.from_pretrained(
                  lowercase__     ,     output_loading_info=lowercase__     ,     from_pt=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	Optional[int]					     =     AutoModelForCausalLM.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
              _snake_case     ,							_snake_case		:	Optional[Any]					     =     AutoModelForCausalLM.from_pretrained(
                  lowercase__     ,     output_loading_info=lowercase__     ,     from_tf=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)







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






        """simple docstring"""





        for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _snake_case		:	List[Any]					     =     AutoConfig.from_pretrained(lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	Tuple					     =     TFAutoModelWithLMHead.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	int					     =     AutoModelWithLMHead.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)







  @slow
  def 				UpperCAmelCase_				(		self		)		->						Any:






        """simple docstring"""





        for model_name in TF_BERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _snake_case		:	List[str]					     =     AutoConfig.from_pretrained(lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	Union[str, Any]					     =     TFAutoModelForMaskedLM.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
              _snake_case     ,							_snake_case		:	List[str]					     =     TFAutoModelForMaskedLM.from_pretrained(
                  lowercase__     ,     output_loading_info=lowercase__     ,     from_pt=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	int					     =     AutoModelForMaskedLM.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
              _snake_case     ,							_snake_case		:	Optional[int]					     =     AutoModelForMaskedLM.from_pretrained(
                  lowercase__     ,     output_loading_info=lowercase__     ,     from_tf=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)







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






        """simple docstring"""





        for model_name in TF_T5_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              _snake_case		:	List[str]					     =     AutoConfig.from_pretrained(lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	Tuple					     =     TFAutoModelForSeqaSeqLM.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
              _snake_case     ,							_snake_case		:	List[str]					     =     TFAutoModelForSeqaSeqLM.from_pretrained(
                  lowercase__     ,     output_loading_info=lowercase__     ,     from_pt=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	List[str]					     =     AutoModelForSeqaSeqLM.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
              _snake_case     ,							_snake_case		:	Dict					     =     AutoModelForSeqaSeqLM.from_pretrained(
                  lowercase__     ,     output_loading_info=lowercase__     ,     from_tf=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)







  @slow
  def 				UpperCAmelCase_				(		self		)		->						Dict:






        """simple docstring"""





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

              _snake_case		:	Any					     =     TFAutoModelForSequenceClassification.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	Dict					     =     AutoModelForSequenceClassification.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)







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






        """simple docstring"""





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

              _snake_case		:	str					     =     TFAutoModelForQuestionAnswering.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)

              _snake_case		:	Union[str, Any]					     =     AutoModelForQuestionAnswering.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
              self.assertIsNotNone(lowercase__		)
              self.assertIsInstance(lowercase__     ,     lowercase__		)







  def 				UpperCAmelCase_				(		self		)		->						str:






        """simple docstring"""





        _snake_case		:	Union[str, Any]					     =     TFAutoModelWithLMHead.from_pretrained(lowercase__     ,     from_pt=lowercase__		)
        self.assertIsInstance(lowercase__     ,     lowercase__		)
        self.assertEqual(model.num_parameters()     ,     14_410		)
        self.assertEqual(model.num_parameters(only_trainable=lowercase__		)     ,     14_410		)

        _snake_case		:	Tuple					     =     AutoModelWithLMHead.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
        self.assertIsInstance(lowercase__     ,     lowercase__		)
        self.assertEqual(model.num_parameters()     ,     14_410		)
        self.assertEqual(model.num_parameters(only_trainable=lowercase__		)     ,     14_410		)







  def 				UpperCAmelCase_				(		self		)		->						str:






        """simple docstring"""





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

        _snake_case		:	int					     =     AutoModelWithLMHead.from_pretrained(lowercase__     ,     from_tf=lowercase__		)
        self.assertIsInstance(lowercase__     ,     lowercase__		)
        self.assertEqual(model.num_parameters()     ,     14_410		)
        self.assertEqual(model.num_parameters(only_trainable=lowercase__		)     ,     14_410		)


