





import unittest

from transformers import DebertaVaConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

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


if is_torch_available():
      import torch

      from transformers import (
          DebertaVaForMaskedLM,
          DebertaVaForMultipleChoice,
          DebertaVaForQuestionAnswering,
          DebertaVaForSequenceClassification,
          DebertaVaForTokenClassification,
          DebertaVaModel,
      )
      from transformers.models.deberta_va.modeling_deberta_va import DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST






class        snake_case_    (		__lowercase						):






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






   '''simple docstring'''

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






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






   '''simple docstring'''

   __lowerCAmelCase					:	Union[str, Any]      =       ids_tensor([self.batch_size, self.seq_length]       ,  self.vocab_size      )

   __lowerCAmelCase					:	Union[str, Any]      =       None
   if self.use_input_mask:
    __lowerCAmelCase					:	Union[str, Any]      =       ids_tensor([self.batch_size, self.seq_length]       ,  vocab_size=2      )

   __lowerCAmelCase					:	Union[str, Any]      =       None
   if self.use_token_type_ids:
    __lowerCAmelCase					:	Dict      =       ids_tensor([self.batch_size, self.seq_length]       ,  self.type_vocab_size      )

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

   __lowerCAmelCase					:	Dict      =       self.get_config()

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






  def 				UpperCAmelCase__						(							self			:					List[Any]      )->Optional[Any]:






   '''simple docstring'''

   return DebertaVaConfig(
       vocab_size=self.vocab_size       ,  hidden_size=self.hidden_size       ,  num_hidden_layers=self.num_hidden_layers       ,  num_attention_heads=self.num_attention_heads       ,  intermediate_size=self.intermediate_size       ,  hidden_act=self.hidden_act       ,  hidden_dropout_prob=self.hidden_dropout_prob       ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,  max_position_embeddings=self.max_position_embeddings       ,  type_vocab_size=self.type_vocab_size       ,  initializer_range=self.initializer_range       ,  relative_attention=self.relative_attention       ,  position_biased_input=self.position_biased_input       ,  pos_att_type=self.pos_att_type       ,  )






  def 				UpperCAmelCase__						(							self			:					Tuple       ,  _snake_case			:					Optional[int]      )->Optional[Any]:






   '''simple docstring'''

   self.parent.assertListEqual(list(result.loss.size()      )       ,  []      )






  def 				UpperCAmelCase__						(							self			:					Dict       ,  _snake_case			:					List[str]       ,  _snake_case			:					List[str]       ,  _snake_case			:					Any       ,  _snake_case			:					List[str]       ,  _snake_case			:					List[str]       ,  _snake_case			:					Tuple       ,  _snake_case			:					Optional[Any]      )->int:






   '''simple docstring'''

   __lowerCAmelCase					:	Tuple      =       DebertaVaModel(config=_snake_case      )
   model.to(_snake_case      )
   model.eval()
   __lowerCAmelCase					:	Optional[Any]      =       model(_snake_case       ,  attention_mask=_snake_case       ,  token_type_ids=_snake_case      )[0]
   __lowerCAmelCase					:	Any      =       model(_snake_case       ,  token_type_ids=_snake_case      )[0]
   __lowerCAmelCase					:	Optional[int]      =       model(_snake_case      )[0]

   self.parent.assertListEqual(list(sequence_output.size()      )       ,  [self.batch_size, self.seq_length, self.hidden_size]      )






  def 				UpperCAmelCase__						(							self			:					Union[str, Any]       ,  _snake_case			:					List[Any]       ,  _snake_case			:					Union[str, Any]       ,  _snake_case			:					Optional[Any]       ,  _snake_case			:					Dict       ,  _snake_case			:					Union[str, Any]       ,  _snake_case			:					Tuple       ,  _snake_case			:					str      )->Optional[int]:






   '''simple docstring'''

   __lowerCAmelCase					:	Optional[int]      =       DebertaVaForMaskedLM(config=_snake_case      )
   model.to(_snake_case      )
   model.eval()
   __lowerCAmelCase					:	Any      =       model(_snake_case       ,  attention_mask=_snake_case       ,  token_type_ids=_snake_case       ,  labels=_snake_case      )

   self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.seq_length, self.vocab_size)      )






  def 				UpperCAmelCase__						(							self			:					List[Any]       ,  _snake_case			:					Optional[Any]       ,  _snake_case			:					str       ,  _snake_case			:					Any       ,  _snake_case			:					List[Any]       ,  _snake_case			:					Optional[int]       ,  _snake_case			:					Optional[int]       ,  _snake_case			:					Optional[Any]      )->Tuple:






   '''simple docstring'''

   __lowerCAmelCase					:	Dict      =       self.num_labels
   __lowerCAmelCase					:	Any      =       DebertaVaForSequenceClassification(_snake_case      )
   model.to(_snake_case      )
   model.eval()
   __lowerCAmelCase					:	Optional[int]      =       model(_snake_case       ,  attention_mask=_snake_case       ,  token_type_ids=_snake_case       ,  labels=_snake_case      )
   self.parent.assertListEqual(list(result.logits.size()      )       ,  [self.batch_size, self.num_labels]      )
   self.check_loss_output(_snake_case      )






  def 				UpperCAmelCase__						(							self			:					int       ,  _snake_case			:					int       ,  _snake_case			:					Any       ,  _snake_case			:					Any       ,  _snake_case			:					Optional[Any]       ,  _snake_case			:					Tuple       ,  _snake_case			:					Any       ,  _snake_case			:					Dict      )->str:






   '''simple docstring'''

   __lowerCAmelCase					:	List[str]      =       self.num_labels
   __lowerCAmelCase					:	List[Any]      =       DebertaVaForTokenClassification(config=_snake_case      )
   model.to(_snake_case      )
   model.eval()
   __lowerCAmelCase					:	Any      =       model(_snake_case       ,  attention_mask=_snake_case       ,  token_type_ids=_snake_case       ,  labels=_snake_case      )
   self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.seq_length, self.num_labels)      )






  def 				UpperCAmelCase__						(							self			:					Optional[Any]       ,  _snake_case			:					Any       ,  _snake_case			:					Any       ,  _snake_case			:					List[Any]       ,  _snake_case			:					Dict       ,  _snake_case			:					List[Any]       ,  _snake_case			:					Any       ,  _snake_case			:					Tuple      )->Union[str, Any]:






   '''simple docstring'''

   __lowerCAmelCase					:	List[str]      =       DebertaVaForQuestionAnswering(config=_snake_case      )
   model.to(_snake_case      )
   model.eval()
   __lowerCAmelCase					:	Dict      =       model(
       _snake_case       ,  attention_mask=_snake_case       ,  token_type_ids=_snake_case       ,  start_positions=_snake_case       ,  end_positions=_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			:					List[str]       ,  _snake_case			:					List[str]       ,  _snake_case			:					Dict       ,  _snake_case			:					Optional[int]       ,  _snake_case			:					Optional[Any]       ,  _snake_case			:					Any       ,  _snake_case			:					Union[str, Any]       ,  _snake_case			:					Any      )->List[str]:






   '''simple docstring'''

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






  def 				UpperCAmelCase__						(							self			:					Dict      )->List[str]:






   '''simple docstring'''

   __lowerCAmelCase					:	str      =       self.prepare_config_and_inputs()
   (
       (
       __lowerCAmelCase
   ) ,					(
       __lowerCAmelCase
   ) ,					(
       __lowerCAmelCase
   ) ,					(
       __lowerCAmelCase
   ) ,					(
       __lowerCAmelCase
   ) ,					(
       __lowerCAmelCase
   ) ,					(
       __lowerCAmelCase
   ) ,					
   )					:	int      =       config_and_inputs
   __lowerCAmelCase					:	Any      =       {"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
   return config, inputs_dict






@require_torch
class        snake_case_    (		__lowercase					,__lowercase					,unittest.TestCase						):
  A_      							=   (
      (
          DebertaVaModel,
          DebertaVaForMaskedLM,
          DebertaVaForSequenceClassification,
          DebertaVaForTokenClassification,
          DebertaVaForQuestionAnswering,
          DebertaVaForMultipleChoice,
      )
      if is_torch_available()
      else ()
  )
  A_      							=   (
      {
          'feature-extraction': DebertaVaModel,
          'fill-mask': DebertaVaForMaskedLM,
          'question-answering': DebertaVaForQuestionAnswering,
          'text-classification': DebertaVaForSequenceClassification,
          'token-classification': DebertaVaForTokenClassification,
          'zero-shot': DebertaVaForSequenceClassification,
      }
      if is_torch_available()
      else {}
  )

  A_      							=   True
  A_      							=   False
  A_      							=   False
  A_      							=   False
  A_      							=   False






  def 				UpperCAmelCase__						(							self			:					Dict      )->List[Any]:






   '''simple docstring'''

   __lowerCAmelCase					:	Optional[int]      =       DebertaVaModelTester(self      )
   __lowerCAmelCase					:	Optional[Any]      =       ConfigTester(self       ,  config_class=_snake_case       ,  hidden_size=37      )






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






   '''simple docstring'''

   self.config_tester.run_common_tests()






  def 				UpperCAmelCase__						(							self			:					Optional[Any]      )->str:






   '''simple docstring'''

   __lowerCAmelCase					:	Optional[int]      =       self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_deberta_model(*_snake_case      )






  def 				UpperCAmelCase__						(							self			:					List[Any]      )->Dict:






   '''simple docstring'''

   __lowerCAmelCase					:	Optional[int]      =       self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_deberta_for_sequence_classification(*_snake_case      )






  def 				UpperCAmelCase__						(							self			:					Tuple      )->str:






   '''simple docstring'''

   __lowerCAmelCase					:	List[str]      =       self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_deberta_for_masked_lm(*_snake_case      )






  def 				UpperCAmelCase__						(							self			:					Tuple      )->Optional[Any]:






   '''simple docstring'''

   __lowerCAmelCase					:	Dict      =       self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_deberta_for_question_answering(*_snake_case      )






  def 				UpperCAmelCase__						(							self			:					Optional[Any]      )->List[Any]:






   '''simple docstring'''

   __lowerCAmelCase					:	Tuple      =       self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_deberta_for_token_classification(*_snake_case      )






  def 				UpperCAmelCase__						(							self			:					Any      )->Optional[int]:






   '''simple docstring'''

   __lowerCAmelCase					:	Dict      =       self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_deberta_for_multiple_choice(*_snake_case      )






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






   '''simple docstring'''

   for model_name in DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
    __lowerCAmelCase					:	int      =       DebertaVaModel.from_pretrained(_snake_case      )
    self.assertIsNotNone(_snake_case      )






@require_torch
@require_sentencepiece
@require_tokenizers
class        snake_case_    (		unittest.TestCase						):






  @unittest.skip(reason="""Model not available yet"""      )
  def 				UpperCAmelCase__						(							self			:					Any      )->int:






   '''simple docstring'''

   pass






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






   '''simple docstring'''

   __lowerCAmelCase					:	int      =       DebertaVaModel.from_pretrained("""microsoft/deberta-v2-xlarge"""      )

   __lowerCAmelCase					:	Dict      =       torch.tensor([[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]]      )
   __lowerCAmelCase					:	List[Any]      =       torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]      )
   with torch.no_grad():
    __lowerCAmelCase					:	Any      =       model(_snake_case       ,  attention_mask=_snake_case      )[0]
   # compare the actual values for a slice.
   __lowerCAmelCase					:	List[str]      =       torch.tensor(
       [[[0.2_356, 0.1_948, 0.0_369], [-0.1_063, 0.3_586, -0.5_152], [-0.6_399, -0.0_259, -0.2_525]]]      )
   self.assertTrue(torch.allclose(output[:, 1:4, 1:4]       ,  _snake_case       ,  atol=1E-4      )       ,  F'''{output[:, 1:4, 1:4]}'''      )






import inspect
import unittest

import numpy as np

from transformers import ViTConfig, is_flax_available
from transformers.testing_utils import require_flax, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor


if is_flax_available():
      import jax

      from transformers.models.vit.modeling_flax_vit import FlaxViTForImageClassification, FlaxViTModel






class        snake_case_    (		unittest.TestCase						):






  def __init__(							self			:					List[Any]       ,  _snake_case			:					List[Any]       ,  _snake_case			:					str=13       ,  _snake_case			:					int=30       ,  _snake_case			:					str=2       ,  _snake_case			:					int=3       ,  _snake_case			:					Optional[Any]=True       ,  _snake_case			:					str=True       ,  _snake_case			:					Optional[int]=32       ,  _snake_case			:					Dict=5       ,  _snake_case			:					Optional[int]=4       ,  _snake_case			:					List[Any]=37       ,  _snake_case			:					Union[str, Any]="gelu"       ,  _snake_case			:					str=0.1       ,  _snake_case			:					str=0.1       ,  _snake_case			:					str=10       ,  _snake_case			:					Any=0.02       ,  )->Tuple:






   '''simple docstring'''

   __lowerCAmelCase					:	Optional[int]      =       parent
   __lowerCAmelCase					:	Any      =       batch_size
   __lowerCAmelCase					:	int      =       image_size
   __lowerCAmelCase					:	int      =       patch_size
   __lowerCAmelCase					:	List[Any]      =       num_channels
   __lowerCAmelCase					:	str      =       is_training
   __lowerCAmelCase					:	str      =       use_labels
   __lowerCAmelCase					:	List[str]      =       hidden_size
   __lowerCAmelCase					:	Dict      =       num_hidden_layers
   __lowerCAmelCase					:	List[str]      =       num_attention_heads
   __lowerCAmelCase					:	Any      =       intermediate_size
   __lowerCAmelCase					:	List[str]      =       hidden_act
   __lowerCAmelCase					:	List[str]      =       hidden_dropout_prob
   __lowerCAmelCase					:	Any      =       attention_probs_dropout_prob
   __lowerCAmelCase					:	Tuple      =       type_sequence_label_size
   __lowerCAmelCase					:	Union[str, Any]      =       initializer_range

   # in ViT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
   __lowerCAmelCase					:	Tuple      =       (image_size // patch_size) ** 2
   __lowerCAmelCase					:	Optional[Any]      =       num_patches + 1






  def 				UpperCAmelCase__						(							self			:					Any      )->Any:






   '''simple docstring'''

   __lowerCAmelCase					:	List[Any]      =       floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]      )

   __lowerCAmelCase					:	Tuple      =       ViTConfig(
       image_size=self.image_size       ,  patch_size=self.patch_size       ,  num_channels=self.num_channels       ,  hidden_size=self.hidden_size       ,  num_hidden_layers=self.num_hidden_layers       ,  num_attention_heads=self.num_attention_heads       ,  intermediate_size=self.intermediate_size       ,  hidden_act=self.hidden_act       ,  hidden_dropout_prob=self.hidden_dropout_prob       ,  attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,  is_decoder=_snake_case       ,  initializer_range=self.initializer_range       ,  )

   return config, pixel_values






  def 				UpperCAmelCase__						(							self			:					List[Any]       ,  _snake_case			:					List[str]       ,  _snake_case			:					List[Any]      )->Any:






   '''simple docstring'''

   __lowerCAmelCase					:	str      =       FlaxViTModel(config=_snake_case      )
   __lowerCAmelCase					:	int      =       model(_snake_case      )
   # expected sequence length = num_patches + 1 (we add 1 for the [CLS] token)
   __lowerCAmelCase					:	Dict      =       (self.image_size, self.image_size)
   __lowerCAmelCase					:	Any      =       (self.patch_size, self.patch_size)
   __lowerCAmelCase					:	Any      =       (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])
   self.parent.assertEqual(result.last_hidden_state.shape       ,  (self.batch_size, num_patches + 1, self.hidden_size)      )






  def 				UpperCAmelCase__						(							self			:					Dict       ,  _snake_case			:					str       ,  _snake_case			:					List[Any]      )->Union[str, Any]:






   '''simple docstring'''

   __lowerCAmelCase					:	Tuple      =       self.type_sequence_label_size
   __lowerCAmelCase					:	Tuple      =       FlaxViTForImageClassification(config=_snake_case      )
   __lowerCAmelCase					:	List[str]      =       model(_snake_case      )
   self.parent.assertEqual(result.logits.shape       ,  (self.batch_size, self.type_sequence_label_size)      )

   # test greyscale images
   __lowerCAmelCase					:	str      =       1
   __lowerCAmelCase					:	Any      =       FlaxViTForImageClassification(_snake_case      )

   __lowerCAmelCase					:	int      =       floats_tensor([self.batch_size, 1, self.image_size, self.image_size]      )
   __lowerCAmelCase					:	Dict      =       model(_snake_case      )






  def 				UpperCAmelCase__						(							self			:					str      )->Any:






   '''simple docstring'''

   __lowerCAmelCase					:	Any      =       self.prepare_config_and_inputs()
   (
       (
       __lowerCAmelCase
   ) ,					(
       __lowerCAmelCase
   ) ,					
   )					:	Union[str, Any]      =       config_and_inputs
   __lowerCAmelCase					:	str      =       {"""pixel_values""": pixel_values}
   return config, inputs_dict






@require_flax
class        snake_case_    (		__lowercase					,unittest.TestCase						):
  A_      							=   (FlaxViTModel, FlaxViTForImageClassification) if is_flax_available() else ()






  def 				UpperCAmelCase__						(							self			:					str      )->None:






   '''simple docstring'''

   __lowerCAmelCase					:	List[str]      =       FlaxViTModelTester(self      )
   __lowerCAmelCase					:	Optional[Any]      =       ConfigTester(self       ,  config_class=_snake_case       ,  has_text_modality=_snake_case       ,  hidden_size=37      )






  def 				UpperCAmelCase__						(							self			:					Any      )->Dict:






   '''simple docstring'''

   self.config_tester.run_common_tests()






  def 				UpperCAmelCase__						(							self			:					Any      )->Any:






   '''simple docstring'''

   __lowerCAmelCase					:	Dict      =       self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_model(*_snake_case      )






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






   '''simple docstring'''

   __lowerCAmelCase					:	Dict      =       self.model_tester.prepare_config_and_inputs()
   self.model_tester.create_and_check_for_image_classification(*_snake_case      )






  def 				UpperCAmelCase__						(							self			:					int      )->int:






   '''simple docstring'''

   __lowerCAmelCase ,					__lowerCAmelCase					:	Any      =       self.model_tester.prepare_config_and_inputs_for_common()

   for model_class in self.all_model_classes:
    __lowerCAmelCase					:	int      =       model_class(_snake_case      )
    __lowerCAmelCase					:	Optional[int]      =       inspect.signature(model.__call__      )
    # signature.parameters is an OrderedDict => so arg_names order is deterministic
    __lowerCAmelCase					:	Tuple      =       [*signature.parameters.keys()]

    __lowerCAmelCase					:	str      =       ["""pixel_values"""]
    self.assertListEqual(arg_names[:1]       ,  _snake_case      )






  def 				UpperCAmelCase__						(							self			:					str      )->str:






   '''simple docstring'''

   __lowerCAmelCase ,					__lowerCAmelCase					:	Any      =       self.model_tester.prepare_config_and_inputs_for_common()

   for model_class in self.all_model_classes:
    with self.subTest(model_class.__name__      ):
     __lowerCAmelCase					:	Optional[int]      =       self._prepare_for_class(_snake_case       ,  _snake_case      )
     __lowerCAmelCase					:	List[str]      =       model_class(_snake_case      )

     @jax.jit
     def model_jitted(_snake_case			:					Dict       ,  **_snake_case			:					Union[str, Any]      ):
      return model(pixel_values=_snake_case       ,  **_snake_case      )

     with self.subTest("""JIT Enabled"""      ):
      __lowerCAmelCase					:	List[Any]      =       model_jitted(**_snake_case      ).to_tuple()

     with self.subTest("""JIT Disabled"""      ):
      with jax.disable_jit():
       __lowerCAmelCase					:	str      =       model_jitted(**_snake_case      ).to_tuple()

     self.assertEqual(len(_snake_case      )       ,  len(_snake_case      )      )
     for jitted_output, output in zip(_snake_case       ,  _snake_case      ):
      self.assertEqual(jitted_output.shape       ,  output.shape      )






  @slow
  def 				UpperCAmelCase__						(							self			:					Dict      )->str:






   '''simple docstring'''

   for model_class_name in self.all_model_classes:
    __lowerCAmelCase					:	List[str]      =       model_class_name.from_pretrained("""google/vit-base-patch16-224"""      )
    __lowerCAmelCase					:	List[str]      =       model(np.ones((1, 3, 224, 224)      )      )
    self.assertIsNotNone(_snake_case      )