

import unittest

from transformers import MraConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask


if is_torch_available():
 import torch

 from transformers import (
     MraForMaskedLM,
     MraForMultipleChoice,
     MraForQuestionAnswering,
     MraForSequenceClassification,
     MraForTokenClassification,
     MraModel,
 )
 from transformers.models.mra.modeling_mra import MRA_PRETRAINED_MODEL_ARCHIVE_LIST







class   __lowercase      :
 def __init__(							self      ,							A_      ,							A_=2      ,							A_=8      ,							A_=True      ,							A_=True      ,							A_=True      ,							A_=True      ,							A_=99      ,							A_=16      ,							A_=5      ,							A_=2      ,							A_=36      ,							A_="gelu"      ,							A_=0.0      ,							A_=0.0      ,							A_=512      ,							A_=16      ,							A_=2      ,							A_=0.02      ,							A_=3      ,							A_=4      ,							A_=None      ,							)					->str:



       '''simple docstring'''





       __lowerCAmelCase					:						Optional[int]					=					parent
       __lowerCAmelCase					:						List[str]					=					batch_size
       __lowerCAmelCase					:						Any					=					seq_length
       __lowerCAmelCase					:						List[Any]					=					is_training
       __lowerCAmelCase					:						Union[str, Any]					=					use_input_mask
       __lowerCAmelCase					:						List[str]					=					use_token_type_ids
       __lowerCAmelCase					:						str					=					use_labels
       __lowerCAmelCase					:						int					=					vocab_size
       __lowerCAmelCase					:						str					=					hidden_size
       __lowerCAmelCase					:						Tuple					=					num_hidden_layers
       __lowerCAmelCase					:						int					=					num_attention_heads
       __lowerCAmelCase					:						Dict					=					intermediate_size
       __lowerCAmelCase					:						Dict					=					hidden_act
       __lowerCAmelCase					:						List[str]					=					hidden_dropout_prob
       __lowerCAmelCase					:						Any					=					attention_probs_dropout_prob
       __lowerCAmelCase					:						Optional[int]					=					max_position_embeddings
       __lowerCAmelCase					:						Dict					=					type_vocab_size
       __lowerCAmelCase					:						Dict					=					type_sequence_label_size
       __lowerCAmelCase					:						Tuple					=					initializer_range
       __lowerCAmelCase					:						Optional[Any]					=					num_labels
       __lowerCAmelCase					:						List[str]					=					num_choices
       __lowerCAmelCase					:						Optional[Any]					=					scope
 def 	UpperCamelCase__  (							self					)					->Tuple:



       '''simple docstring'''





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

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

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

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

       __lowerCAmelCase					:						str					=					self.get_config()

       return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
 def 	UpperCamelCase__  (							self					)					->Any:



       '''simple docstring'''





       return MraConfig(
           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      ,							is_decoder=snake_case_      ,							initializer_range=self.initializer_range      ,							)
 def 	UpperCamelCase__  (							self					)					->Union[str, Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						List[str]					=					self.get_config()
       __lowerCAmelCase					:						Tuple					=					300
       return config
 def 	UpperCamelCase__  (							self					)					->Any:



       '''simple docstring'''





       (
           (
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							  
       )					:						Optional[Any]					=					self.prepare_config_and_inputs()

       __lowerCAmelCase					:						str					=					True
       __lowerCAmelCase					:						Union[str, Any]					=					floats_tensor([self.batch_size, self.seq_length, self.hidden_size]					)
       __lowerCAmelCase					:						Optional[int]					=					ids_tensor([self.batch_size, self.seq_length]      ,							vocab_size=2					)

       return (
           config,
           input_ids,
           token_type_ids,
           input_mask,
           sequence_labels,
           token_labels,
           choice_labels,
           encoder_hidden_states,
           encoder_attention_mask,
       )
 def 	UpperCamelCase__  (							self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_					)					->List[str]:



       '''simple docstring'''





       __lowerCAmelCase					:						int					=					MraModel(config=snake_case_					)
       model.to(snake_case_					)
       model.eval()
       __lowerCAmelCase					:						List[Any]					=					model(snake_case_      ,							attention_mask=snake_case_      ,							token_type_ids=snake_case_					)
       __lowerCAmelCase					:						Optional[Any]					=					model(snake_case_      ,							token_type_ids=snake_case_					)
       __lowerCAmelCase					:						str					=					model(snake_case_					)
       self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, self.seq_length, self.hidden_size)					)
 def 	UpperCamelCase__  (							self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							)					->Optional[Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						str					=					True
       __lowerCAmelCase					:						Union[str, Any]					=					MraModel(snake_case_					)
       model.to(snake_case_					)
       model.eval()
       __lowerCAmelCase					:						Optional[int]					=					model(
           snake_case_      ,							attention_mask=snake_case_      ,							token_type_ids=snake_case_      ,							encoder_hidden_states=snake_case_      ,							encoder_attention_mask=snake_case_      ,							)
       __lowerCAmelCase					:						Optional[Any]					=					model(
           snake_case_      ,							attention_mask=snake_case_      ,							token_type_ids=snake_case_      ,							encoder_hidden_states=snake_case_      ,							)
       __lowerCAmelCase					:						Dict					=					model(snake_case_      ,							attention_mask=snake_case_      ,							token_type_ids=snake_case_					)
       self.parent.assertEqual(result.last_hidden_state.shape      ,							(self.batch_size, self.seq_length, self.hidden_size)					)
 def 	UpperCamelCase__  (							self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_					)					->Optional[Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						str					=					MraForMaskedLM(config=snake_case_					)
       model.to(snake_case_					)
       model.eval()
       __lowerCAmelCase					:						List[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      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_					)					->Optional[Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						List[str]					=					MraForQuestionAnswering(config=snake_case_					)
       model.to(snake_case_					)
       model.eval()
       __lowerCAmelCase					:						Optional[Any]					=					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      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_					)					->Optional[int]:



       '''simple docstring'''





       __lowerCAmelCase					:						Optional[Any]					=					self.num_labels
       __lowerCAmelCase					:						int					=					MraForSequenceClassification(snake_case_					)
       model.to(snake_case_					)
       model.eval()
       __lowerCAmelCase					:						Optional[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.num_labels)					)
 def 	UpperCamelCase__  (							self      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_					)					->List[str]:



       '''simple docstring'''





       __lowerCAmelCase					:						List[Any]					=					self.num_labels
       __lowerCAmelCase					:						Any					=					MraForTokenClassification(config=snake_case_					)
       model.to(snake_case_					)
       model.eval()
       __lowerCAmelCase					:						Dict					=					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      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_      ,							A_					)					->int:



       '''simple docstring'''





       __lowerCAmelCase					:						str					=					self.num_choices
       __lowerCAmelCase					:						Optional[Any]					=					MraForMultipleChoice(config=snake_case_					)
       model.to(snake_case_					)
       model.eval()
       __lowerCAmelCase					:						str					=					input_ids.unsqueeze(1					).expand(-1      ,							self.num_choices      ,							-1					).contiguous()
       __lowerCAmelCase					:						str					=					token_type_ids.unsqueeze(1					).expand(-1      ,							self.num_choices      ,							-1					).contiguous()
       __lowerCAmelCase					:						List[Any]					=					input_mask.unsqueeze(1					).expand(-1      ,							self.num_choices      ,							-1					).contiguous()
       __lowerCAmelCase					:						Optional[int]					=					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					)					->int:



       '''simple docstring'''





       __lowerCAmelCase					:						Optional[Any]					=					self.prepare_config_and_inputs()
       (
           (
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							(
           __lowerCAmelCase  
       ),							  
       )					:						Optional[Any]					=					config_and_inputs
       __lowerCAmelCase					:						Tuple					=					{'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
       return config, inputs_dict







@require_torch
class   __lowercase      (lowerCAmelCase_		,   unittest.TestCase ):
 _UpperCamelCase			  =  (
     (
         MraModel,
         MraForMaskedLM,
         MraForMultipleChoice,
         MraForQuestionAnswering,
         MraForSequenceClassification,
         MraForTokenClassification,
     )
     if is_torch_available()
     else ()
 )
 _UpperCamelCase			  =  False
 _UpperCamelCase			  =  False
 _UpperCamelCase			  =  False
 _UpperCamelCase			  =  False

 _UpperCamelCase			  =  ()
 def 	UpperCamelCase__  (							self					)					->List[Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						Optional[Any]					=					MraModelTester(self					)
       __lowerCAmelCase					:						Optional[Any]					=					ConfigTester(self      ,							config_class=snake_case_      ,							hidden_size=37					)
 def 	UpperCamelCase__  (							self					)					->Dict:



       '''simple docstring'''





       self.config_tester.run_common_tests()
 def 	UpperCamelCase__  (							self					)					->Tuple:



       '''simple docstring'''





       __lowerCAmelCase					:						int					=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*snake_case_					)
 def 	UpperCamelCase__  (							self					)					->Any:



       '''simple docstring'''





       __lowerCAmelCase					:						int					=					self.model_tester.prepare_config_and_inputs()
       for type in ["absolute", "relative_key", "relative_key_query"]:
             __lowerCAmelCase					:						Any					=					type
             self.model_tester.create_and_check_model(*snake_case_					)
 def 	UpperCamelCase__  (							self					)					->List[str]:



       '''simple docstring'''





       __lowerCAmelCase					:						Tuple					=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_lm(*snake_case_					)
 def 	UpperCamelCase__  (							self					)					->int:



       '''simple docstring'''





       __lowerCAmelCase					:						Any					=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_multiple_choice(*snake_case_					)
 def 	UpperCamelCase__  (							self					)					->int:



       '''simple docstring'''





       __lowerCAmelCase					:						int					=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_question_answering(*snake_case_					)
 def 	UpperCamelCase__  (							self					)					->Optional[int]:



       '''simple docstring'''





       __lowerCAmelCase					:						int					=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_sequence_classification(*snake_case_					)
 def 	UpperCamelCase__  (							self					)					->Optional[Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						Dict					=					self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_token_classification(*snake_case_					)
 @slow
 def 	UpperCamelCase__  (							self					)					->str:



       '''simple docstring'''





       for model_name in MRA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
             __lowerCAmelCase					:						Any					=					MraModel.from_pretrained(snake_case_					)
             self.assertIsNotNone(snake_case_					)





 @unittest.skip(reason='''MRA does not output attentions'''					)
 def 	UpperCamelCase__  (							self					)					->Tuple:



       '''simple docstring'''





       return







@require_torch
class   __lowercase      (unittest.TestCase ):
 @slow
 def 	UpperCamelCase__  (							self					)					->str:



       '''simple docstring'''





       __lowerCAmelCase					:						Tuple					=					MraModel.from_pretrained('''uw-madison/mra-base-512-4'''					)
       __lowerCAmelCase					:						Tuple					=					torch.arange(256					).unsqueeze(0					)

       with torch.no_grad():
             __lowerCAmelCase					:						Optional[int]					=					model(snake_case_					)[0]

       __lowerCAmelCase					:						str					=					torch.Size((1, 256, 768)					)
       self.assertEqual(output.shape      ,							snake_case_					)

       __lowerCAmelCase					:						str					=					torch.tensor(
           [[[-0.0_140, 0.0_830, -0.0_381], [0.1_546, 0.1_402, 0.0_220], [0.1_162, 0.0_851, 0.0_165]]]					)

       self.assertTrue(torch.allclose(output[:, :3, :3]      ,							snake_case_      ,							atol=1e-4					)					)
 @slow
 def 	UpperCamelCase__  (							self					)					->Union[str, Any]:



       '''simple docstring'''





       __lowerCAmelCase					:						Dict					=					MraForMaskedLM.from_pretrained('''uw-madison/mra-base-512-4'''					)
       __lowerCAmelCase					:						Any					=					torch.arange(256					).unsqueeze(0					)

       with torch.no_grad():
             __lowerCAmelCase					:						Tuple					=					model(snake_case_					)[0]

       __lowerCAmelCase					:						Any					=					5_0265

       __lowerCAmelCase					:						int					=					torch.Size((1, 256, vocab_size)					)
       self.assertEqual(output.shape      ,							snake_case_					)

       __lowerCAmelCase					:						Union[str, Any]					=					torch.tensor(
           [[[9.2_595, -3.6_038, 11.8819], [9.3_869, -3.2_693, 11.0956], [11.8524, -3.4_938, 13.1210]]]					)

       self.assertTrue(torch.allclose(output[:, :3, :3]      ,							snake_case_      ,							atol=1e-4					)					)





 @slow
 def 	UpperCamelCase__  (							self					)					->Dict:



       '''simple docstring'''





       __lowerCAmelCase					:						Tuple					=					MraForMaskedLM.from_pretrained('''uw-madison/mra-base-4096-8-d3'''					)
       __lowerCAmelCase					:						str					=					torch.arange(4096					).unsqueeze(0					)

       with torch.no_grad():
             __lowerCAmelCase					:						Dict					=					model(snake_case_					)[0]

       __lowerCAmelCase					:						List[str]					=					5_0265

       __lowerCAmelCase					:						Optional[Any]					=					torch.Size((1, 4096, vocab_size)					)
       self.assertEqual(output.shape      ,							snake_case_					)

       __lowerCAmelCase					:						Optional[Any]					=					torch.tensor(
           [[[5.4_789, -2.3_564, 7.5_064], [7.9_067, -1.3_369, 9.9_668], [9.0_712, -1.8_106, 7.0_380]]]					)

       self.assertTrue(torch.allclose(output[:, :3, :3]      ,							snake_case_      ,							atol=1e-4					)					)









'''simple docstring'''




from collections import OrderedDict
from typing import Any, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...feature_extraction_utils import FeatureExtractionMixin
from ...onnx import OnnxConfig
from ...onnx.utils import compute_effective_axis_dimension
from ...tokenization_utils_base import PreTrainedTokenizerBase
from ...utils import TensorType, logging


__SCREAMING_SNAKE_CASE     :Dict       =				logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE     :int       =				{
    '''deepmind/language-perceiver''': '''https://huggingface.co/deepmind/language-perceiver/resolve/main/config.json''',
    # See all Perceiver models at https://huggingface.co/models?filter=perceiver
}







class   A_	(  lowerCAmelCase_			):
 _lowerCamelCase  : int           =							"""perceiver"""




 def __init__(					self       :    Any	,			snake_case_       :    List[Any]=2_5_6	,			snake_case_       :    str=1_2_8_0	,			snake_case_       :    Optional[int]=7_6_8	,			snake_case_       :    int=1	,			snake_case_       :    List[Any]=2_6	,			snake_case_       :    Dict=8	,			snake_case_       :    List[Any]=8	,			snake_case_       :    Tuple=None	,			snake_case_       :    Tuple=None	,			snake_case_       :    Any="kv"	,			snake_case_       :    Any=1	,			snake_case_       :    List[str]=1	,			snake_case_       :    Optional[int]="gelu"	,			snake_case_       :    List[Any]=0.1	,			snake_case_       :    Dict=0.0_2	,			snake_case_       :    int=1e-12	,			snake_case_       :    List[str]=True	,			snake_case_       :    str=2_6_2	,			snake_case_       :    Optional[Any]=2_0_4_8	,			snake_case_       :    Union[str, Any]=5_6	,			snake_case_       :    Dict=[3_6_8, 4_9_6]	,			snake_case_       :    Tuple=1_6	,			snake_case_       :    Union[str, Any]=1_9_2_0	,			snake_case_       :    List[Any]=1_6	,			snake_case_       :    Tuple=[1, 1_6, 2_2_4, 2_2_4]	,			**snake_case_       :    List[Any]	,			):
      super().__init__(**snake_case_    )

      _UpperCAmelCase     							=   num_latents
      _UpperCAmelCase     							=   d_latents
      _UpperCAmelCase     							=   d_model
      _UpperCAmelCase     							=   num_blocks
      _UpperCAmelCase     							=   num_self_attends_per_block
      _UpperCAmelCase     							=   num_self_attention_heads
      _UpperCAmelCase     							=   num_cross_attention_heads
      _UpperCAmelCase     							=   qk_channels
      _UpperCAmelCase     							=   v_channels
      _UpperCAmelCase     							=   cross_attention_shape_for_attention
      _UpperCAmelCase     							=   self_attention_widening_factor
      _UpperCAmelCase     							=   cross_attention_widening_factor
      _UpperCAmelCase     							=   hidden_act
      _UpperCAmelCase     							=   attention_probs_dropout_prob
      _UpperCAmelCase     							=   initializer_range
      _UpperCAmelCase     							=   layer_norm_eps
      _UpperCAmelCase     							=   use_query_residual
      # masked language modeling attributes
      _UpperCAmelCase     							=   vocab_size
      _UpperCAmelCase     							=   max_position_embeddings
      # image classification attributes
      _UpperCAmelCase     							=   image_size
      # flow attributes
      _UpperCAmelCase     							=   train_size
      # multimodal autoencoding attributes
      _UpperCAmelCase     							=   num_frames
      _UpperCAmelCase     							=   audio_samples_per_frame
      _UpperCAmelCase     							=   samples_per_patch
      _UpperCAmelCase     							=   output_shape







class   A_	(  lowerCAmelCase_			):




 @property
 def      lowercase	(					self       :    int    ):
      if self.task == "multiple-choice":
           _UpperCAmelCase     							=   {0: "batch", 1: "choice", 2: "sequence"}
      else:
           _UpperCAmelCase     							=   {0: "batch", 1: "sequence"}
      return OrderedDict(
          [
              ("inputs", dynamic_axis),
              ("attention_mask", dynamic_axis),
          ]    )




 @property
 def      lowercase	(					self       :    Optional[Any]    ):
      return 1e-4




 def      lowercase	(					self       :    List[str]	,			snake_case_       :    Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]	,			snake_case_       :    int = -1	,			snake_case_       :    int = -1	,			snake_case_       :    int = -1	,			snake_case_       :    bool = False	,			snake_case_       :    Optional[TensorType] = None	,			snake_case_       :    int = 3	,			snake_case_       :    int = 4_0	,			snake_case_       :    int = 4_0	,			):
      # copied from `transformers.onnx.config.OnnxConfig` and slightly altered/simplified

      if isinstance(snake_case_	,			snake_case_    ):
           # If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
           _UpperCAmelCase     							=   compute_effective_axis_dimension(
               snake_case_	,			fixed_dimension=OnnxConfig.default_fixed_batch	,			num_token_to_add=0    )
           # If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
           _UpperCAmelCase     							=   preprocessor.num_special_tokens_to_add(snake_case_    )
           _UpperCAmelCase     							=   compute_effective_axis_dimension(
               snake_case_	,			fixed_dimension=OnnxConfig.default_fixed_sequence	,			num_token_to_add=snake_case_    )
           # Generate dummy inputs according to compute batch and sequence
           _UpperCAmelCase     							=   [" ".join(["a"]    ) * seq_length] * batch_size
           _UpperCAmelCase     							=   dict(preprocessor(snake_case_	,			return_tensors=snake_case_    )    )
           _UpperCAmelCase     							=   inputs.pop("input_ids"    )
           return inputs
      elif isinstance(snake_case_	,			snake_case_    ) and preprocessor.model_input_names[0] == "pixel_values":
           # If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
           _UpperCAmelCase     							=   compute_effective_axis_dimension(snake_case_	,			fixed_dimension=OnnxConfig.default_fixed_batch    )
           _UpperCAmelCase     							=   self._generate_dummy_images(snake_case_	,			snake_case_	,			snake_case_	,			snake_case_    )
           _UpperCAmelCase     							=   dict(preprocessor(images=snake_case_	,			return_tensors=snake_case_    )    )
           _UpperCAmelCase     							=   inputs.pop("pixel_values"    )
           return inputs
      else:
           raise ValueError(
               "Unable to generate dummy inputs for the model. Please provide a tokenizer or a preprocessor."    )




