






import inspect
import unittest

from transformers import ResNetConfig, is_flax_available
from transformers.testing_utils import require_flax, slow
from transformers.utils import cached_property, is_vision_available

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


if is_flax_available():
							import jax
							import jax.numpy as jnp

							from transformers.models.resnet.modeling_flax_resnet import FlaxResNetForImageClassification, FlaxResNetModel

if is_vision_available():
							from PIL import Image

							from transformers import AutoImageProcessor




class 						UpperCAmelCase_  (		unittest.TestCase    ):


						'''simple docstring'''




						def __init__(		self						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE=3						, _SCREAMING_SNAKE_CASE=32						, _SCREAMING_SNAKE_CASE=3						, _SCREAMING_SNAKE_CASE=10						, _SCREAMING_SNAKE_CASE=[10, 20, 30, 40]						, _SCREAMING_SNAKE_CASE=[1, 1, 2, 1]						, _SCREAMING_SNAKE_CASE=True						, _SCREAMING_SNAKE_CASE=True						, _SCREAMING_SNAKE_CASE="relu"						, _SCREAMING_SNAKE_CASE=3						, _SCREAMING_SNAKE_CASE=None						, )       -> List[Any]:
								snake_case_ :							Dict         =				parent
								snake_case_ :							str         =				batch_size
								snake_case_ :							Tuple         =				image_size
								snake_case_ :							str         =				num_channels
								snake_case_ :							Dict         =				embeddings_size
								snake_case_ :							List[Any]         =				hidden_sizes
								snake_case_ :							Optional[Any]         =				depths
								snake_case_ :							Tuple         =				is_training
								snake_case_ :							Optional[int]         =				use_labels
								snake_case_ :							Optional[int]         =				hidden_act
								snake_case_ :							Optional[int]         =				num_labels
								snake_case_ :							Union[str, Any]         =				scope
								snake_case_ :							List[Any]         =				len(_SCREAMING_SNAKE_CASE )






						def 					_lowerCAmelCase				(		self )       -> int:
								snake_case_ :							Dict         =				floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size] )

								snake_case_ :							Union[str, Any]         =				self.get_config()

								return config, pixel_values






						def 					_lowerCAmelCase				(		self )       -> Optional[Any]:
								return ResNetConfig(
								    num_channels=self.num_channels						, embeddings_size=self.embeddings_size						, hidden_sizes=self.hidden_sizes						, depths=self.depths						, hidden_act=self.hidden_act						, num_labels=self.num_labels						, image_size=self.image_size						, )






						def 					_lowerCAmelCase				(		self						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )       -> Dict:
								snake_case_ :							Union[str, Any]         =				FlaxResNetModel(config=_SCREAMING_SNAKE_CASE )
								snake_case_ :							Optional[int]         =				model(_SCREAMING_SNAKE_CASE )

								# Output shape (b, c, h, w)
								self.parent.assertEqual(
								    result.last_hidden_state.shape						, (self.batch_size, self.hidden_sizes[-1], self.image_size // 32, self.image_size // 32)						, )






						def 					_lowerCAmelCase				(		self						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )       -> List[Any]:
								snake_case_ :							str         =				self.num_labels
								snake_case_ :							List[Any]         =				FlaxResNetForImageClassification(config=_SCREAMING_SNAKE_CASE )
								snake_case_ :							Any         =				model(_SCREAMING_SNAKE_CASE )
								self.parent.assertEqual(result.logits.shape						, (self.batch_size, self.num_labels) )






						def 					_lowerCAmelCase				(		self )       -> Optional[int]:
								snake_case_ :							Tuple         =				self.prepare_config_and_inputs()
								snake_case_       ,				snake_case_ :							Optional[Any]         =				config_and_inputs
								snake_case_ :							Any         =				{"pixel_values": pixel_values}
								return config, inputs_dict




@require_flax
class 						UpperCAmelCase_  (		SCREAMING_SNAKE_CASE__    ,     unittest.TestCase    ):


						'''simple docstring'''




						A   :      Dict						 =    (FlaxResNetModel, FlaxResNetForImageClassification) if is_flax_available() else ()

						A   :      int						 =    False
						A   :      int						 =    False
						A   :      str						 =    False






						def 					_lowerCAmelCase				(		self )       -> None:
								snake_case_ :							int         =				FlaxResNetModelTester(self )
								snake_case_ :							Optional[Any]         =				ConfigTester(self						, config_class=_SCREAMING_SNAKE_CASE						, has_text_modality=_SCREAMING_SNAKE_CASE )






						def 					_lowerCAmelCase				(		self )       -> List[Any]:
								self.create_and_test_config_common_properties()
								self.config_tester.create_and_test_config_to_json_string()
								self.config_tester.create_and_test_config_to_json_file()
								self.config_tester.create_and_test_config_from_and_save_pretrained()
								self.config_tester.create_and_test_config_with_num_labels()
								self.config_tester.check_config_can_be_init_without_params()
								self.config_tester.check_config_arguments_init()






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






						def 					_lowerCAmelCase				(		self )       -> int:
								snake_case_ :							Union[str, Any]         =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE )






						def 					_lowerCAmelCase				(		self )       -> Optional[int]:
								snake_case_ :							Optional[Any]         =				self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_classification(*_SCREAMING_SNAKE_CASE )






						@unittest.skip(reason="ResNet does not use inputs_embeds" )
						def 					_lowerCAmelCase				(		self )       -> Optional[int]:
								pass






						@unittest.skip(reason="ResNet does not support input and output embeddings" )
						def 					_lowerCAmelCase				(		self )       -> int:
								pass






						def 					_lowerCAmelCase				(		self )       -> Tuple:
								snake_case_       ,				snake_case_ :							Optional[int]         =				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
										snake_case_ :							int         =				model_class(_SCREAMING_SNAKE_CASE )
										snake_case_ :							Union[str, Any]         =				inspect.signature(model.__call__ )
										# signature.parameters is an OrderedDict => so arg_names order is deterministic
										snake_case_ :							List[str]         =				[*signature.parameters.keys()]

										snake_case_ :							int         =				["pixel_values"]
										self.assertListEqual(arg_names[:1]						, _SCREAMING_SNAKE_CASE )






						def 					_lowerCAmelCase				(		self )       -> Tuple:
								def check_hidden_states_output(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE ):
										snake_case_ :							Optional[int]         =				model_class(_SCREAMING_SNAKE_CASE )

										snake_case_ :							Tuple         =				model(**self._prepare_for_class(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE ) )

										snake_case_ :							Dict         =				outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

										snake_case_ :							Any         =				self.model_tester.num_stages
										self.assertEqual(len(_SCREAMING_SNAKE_CASE )						, expected_num_stages + 1 )






						@unittest.skip(reason="ResNet does not use feedforward chunking" )
						def 					_lowerCAmelCase				(		self )       -> str:
								pass






						def 					_lowerCAmelCase				(		self )       -> Tuple:
								snake_case_       ,				snake_case_ :							Union[str, Any]         =				self.model_tester.prepare_config_and_inputs_for_common()

								for model_class in self.all_model_classes:
										with self.subTest(model_class.__name__ ):
												snake_case_ :							Optional[Any]         =				self._prepare_for_class(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )
												snake_case_ :							Dict         =				model_class(_SCREAMING_SNAKE_CASE )

												@jax.jit
												def model_jitted(_SCREAMING_SNAKE_CASE						, **_SCREAMING_SNAKE_CASE ):
														return model(pixel_values=_SCREAMING_SNAKE_CASE						, **_SCREAMING_SNAKE_CASE )

												with self.subTest("JIT Enabled" ):
														snake_case_ :							Any         =				model_jitted(**_SCREAMING_SNAKE_CASE ).to_tuple()

												with self.subTest("JIT Disabled" ):
														with jax.disable_jit():
																snake_case_ :							List[Any]         =				model_jitted(**_SCREAMING_SNAKE_CASE ).to_tuple()

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




def    lowerCAmelCase__		(			):
		snake_case_ :							Dict         =				Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"			)
		return image




@require_flax
class 						UpperCAmelCase_  (		unittest.TestCase    ):


						'''simple docstring'''




						@cached_property
						def 					_lowerCAmelCase				(		self )       -> str:
								return AutoImageProcessor.from_pretrained("microsoft/resnet-50" ) if is_vision_available() else None






						@slow
						def 					_lowerCAmelCase				(		self )       -> int:
								snake_case_ :							List[str]         =				FlaxResNetForImageClassification.from_pretrained("microsoft/resnet-50" )

								snake_case_ :							str         =				self.default_image_processor
								snake_case_ :							int         =				prepare_img()
								snake_case_ :							Union[str, Any]         =				image_processor(images=_SCREAMING_SNAKE_CASE						, return_tensors="np" )

								snake_case_ :							Any         =				model(**_SCREAMING_SNAKE_CASE )

								# verify the logits
								snake_case_ :							List[str]         =				(1, 1000)
								self.assertEqual(outputs.logits.shape						, _SCREAMING_SNAKE_CASE )

								snake_case_ :							Optional[Any]         =				jnp.array([-11.1069, -9.7877, -8.3777] )

								self.assertTrue(jnp.allclose(outputs.logits[0, :3]						, _SCREAMING_SNAKE_CASE						, atol=1e-4 ) )








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

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import TensorType, is_torch_available, logging


lowercase     :							List[str]	     =			logging.get_logger(__name__)

lowercase     :							int	     =			{
    '''google/bigbird-pegasus-large-arxiv''': (
        '''https://huggingface.co/google/bigbird-pegasus-large-arxiv/resolve/main/config.json'''
    ),
    '''google/bigbird-pegasus-large-pubmed''': (
        '''https://huggingface.co/google/bigbird-pegasus-large-pubmed/resolve/main/config.json'''
    ),
    '''google/bigbird-pegasus-large-bigpatent''': (
        '''https://huggingface.co/google/bigbird-pegasus-large-bigpatent/resolve/main/config.json'''
    ),
    # See all BigBirdPegasus models at https://huggingface.co/models?filter=bigbird_pegasus
}




class 						UpperCAmelCase_  (		SCREAMING_SNAKE_CASE__    ):


						'''simple docstring'''




						A   :      List[str]						 =    'bigbird_pegasus'
						A   :      Optional[int]						 =    ['past_key_values']
						A   :      Tuple						 =    {
						    'num_attention_heads': 'encoder_attention_heads',
						    'hidden_size': 'd_model',
						    'attention_probs_dropout_prob': 'attention_dropout',
						}






						def __init__(		self						, _SCREAMING_SNAKE_CASE=9_6103						, _SCREAMING_SNAKE_CASE=4096						, _SCREAMING_SNAKE_CASE=16						, _SCREAMING_SNAKE_CASE=4096						, _SCREAMING_SNAKE_CASE=16						, _SCREAMING_SNAKE_CASE=16						, _SCREAMING_SNAKE_CASE=4096						, _SCREAMING_SNAKE_CASE=16						, _SCREAMING_SNAKE_CASE=0.0						, _SCREAMING_SNAKE_CASE=0.0						, _SCREAMING_SNAKE_CASE=True						, _SCREAMING_SNAKE_CASE=True						, _SCREAMING_SNAKE_CASE="gelu_new"						, _SCREAMING_SNAKE_CASE=1024						, _SCREAMING_SNAKE_CASE=0.1						, _SCREAMING_SNAKE_CASE=0.0						, _SCREAMING_SNAKE_CASE=0.0						, _SCREAMING_SNAKE_CASE=0.02						, _SCREAMING_SNAKE_CASE=2						, _SCREAMING_SNAKE_CASE=0.0						, _SCREAMING_SNAKE_CASE=True						, _SCREAMING_SNAKE_CASE=0						, _SCREAMING_SNAKE_CASE=2						, _SCREAMING_SNAKE_CASE=1						, _SCREAMING_SNAKE_CASE="block_sparse"						, _SCREAMING_SNAKE_CASE=64						, _SCREAMING_SNAKE_CASE=3						, _SCREAMING_SNAKE_CASE=False						, **_SCREAMING_SNAKE_CASE						, )       -> Dict:
								snake_case_ :							str         =				vocab_size
								snake_case_ :							Tuple         =				max_position_embeddings
								snake_case_ :							List[Any]         =				d_model
								snake_case_ :							List[str]         =				encoder_ffn_dim
								snake_case_ :							List[str]         =				encoder_layers
								snake_case_ :							int         =				encoder_attention_heads
								snake_case_ :							Tuple         =				decoder_ffn_dim
								snake_case_ :							List[Any]         =				decoder_layers
								snake_case_ :							Optional[int]         =				decoder_attention_heads
								snake_case_ :							Any         =				dropout
								snake_case_ :							Tuple         =				attention_dropout
								snake_case_ :							List[str]         =				activation_dropout
								snake_case_ :							Any         =				activation_function
								snake_case_ :							Any         =				init_std
								snake_case_ :							Optional[int]         =				encoder_layerdrop
								snake_case_ :							Optional[Any]         =				decoder_layerdrop
								snake_case_ :							Tuple         =				classifier_dropout
								snake_case_ :							str         =				use_cache
								snake_case_ :							Dict         =				encoder_layers
								snake_case_ :							List[str]         =				scale_embedding  # scale factor will be sqrt(d_model) if True

								# extra config
								snake_case_ :							Union[str, Any]         =				attention_type
								snake_case_ :							Tuple         =				block_size
								snake_case_ :							Any         =				num_random_blocks
								snake_case_ :							List[str]         =				use_bias

								super().__init__(
								    pad_token_id=_SCREAMING_SNAKE_CASE						, bos_token_id=_SCREAMING_SNAKE_CASE						, eos_token_id=_SCREAMING_SNAKE_CASE						, is_encoder_decoder=_SCREAMING_SNAKE_CASE						, decoder_start_token_id=_SCREAMING_SNAKE_CASE						, **_SCREAMING_SNAKE_CASE						, )




class 						UpperCAmelCase_  (		SCREAMING_SNAKE_CASE__    ):


						'''simple docstring'''




						@property
						def 					_lowerCAmelCase				(		self )       -> Mapping[str, Mapping[int, str]]:
								if self.task in ["default", "seq2seq-lm"]:
										snake_case_ :							str         =				OrderedDict(
										    [
										        ("input_ids", {0: "batch", 1: "encoder_sequence"}),
										        ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
										    ] )

										if self.use_past:
												snake_case_ :							List[str]         =				{0: "batch"}
												snake_case_ :							Dict         =				{0: "batch", 1: "past_decoder_sequence + sequence"}
										else:
												snake_case_ :							Any         =				{0: "batch", 1: "decoder_sequence"}
												snake_case_ :							int         =				{0: "batch", 1: "decoder_sequence"}

										if self.use_past:
												self.fill_with_past_key_values_(_SCREAMING_SNAKE_CASE						, direction="inputs" )
								elif self.task == "causal-lm":
										# TODO: figure this case out.
										snake_case_ :							Union[str, Any]         =				OrderedDict(
										    [
										        ("input_ids", {0: "batch", 1: "encoder_sequence"}),
										        ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
										    ] )
										if self.use_past:
												snake_case_       ,				snake_case_ :							Tuple         =				self.num_layers
												for i in range(_SCREAMING_SNAKE_CASE ):
														snake_case_ :							int         =				{0: "batch", 2: "past_sequence + sequence"}
														snake_case_ :							Dict         =				{0: "batch", 2: "past_sequence + sequence"}
								else:
										snake_case_ :							Union[str, Any]         =				OrderedDict(
										    [
										        ("input_ids", {0: "batch", 1: "encoder_sequence"}),
										        ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
										        ("decoder_input_ids", {0: "batch", 1: "decoder_sequence"}),
										        ("decoder_attention_mask", {0: "batch", 1: "decoder_sequence"}),
										    ] )

								return common_inputs






						@property
						def 					_lowerCAmelCase				(		self )       -> Mapping[str, Mapping[int, str]]:
								if self.task in ["default", "seq2seq-lm"]:
										snake_case_ :							str         =				super().outputs
								else:
										snake_case_ :							Optional[Any]         =				super(_SCREAMING_SNAKE_CASE						, self ).outputs
										if self.use_past:
												snake_case_       ,				snake_case_ :							Optional[int]         =				self.num_layers
												for i in range(_SCREAMING_SNAKE_CASE ):
														snake_case_ :							Tuple         =				{0: "batch", 2: "past_sequence + sequence"}
														snake_case_ :							Union[str, Any]         =				{0: "batch", 2: "past_sequence + sequence"}
								return common_outputs






						def 					_lowerCAmelCase				(		self						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE = -1						, _SCREAMING_SNAKE_CASE = -1						, _SCREAMING_SNAKE_CASE = False						, _SCREAMING_SNAKE_CASE = None						, )       -> Mapping[str, Any]:
								snake_case_ :							List[str]         =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
								    _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )

								# Generate decoder inputs
								snake_case_ :							Optional[int]         =				seq_length if not self.use_past else 1
								snake_case_ :							Dict         =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
								    _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )
								snake_case_ :							List[Any]         =				{f'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
								snake_case_ :							str         =				dict(**_SCREAMING_SNAKE_CASE						, **_SCREAMING_SNAKE_CASE )

								if self.use_past:
										if not is_torch_available():
												raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed." )
										else:
												import torch
										snake_case_       ,				snake_case_ :							str         =				common_inputs["input_ids"].shape
										snake_case_ :							List[str]         =				common_inputs["decoder_input_ids"].shape[1]
										snake_case_       ,				snake_case_ :							Tuple         =				self.num_attention_heads
										snake_case_ :							List[Any]         =				(
										    batch,
										    num_encoder_attention_heads,
										    encoder_seq_length,
										    self._config.hidden_size // num_encoder_attention_heads,
										)
										snake_case_ :							Optional[Any]         =				decoder_seq_length + 3
										snake_case_ :							Any         =				(
										    batch,
										    num_decoder_attention_heads,
										    decoder_past_length,
										    self._config.hidden_size // num_decoder_attention_heads,
										)

										snake_case_ :							Optional[Any]         =				torch.cat(
										    [common_inputs["decoder_attention_mask"], torch.ones(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )]						, dim=1 )

										snake_case_ :							int         =				[]
										# If the number of encoder and decoder layers are present in the model configuration, both are considered
										snake_case_       ,				snake_case_ :							Any         =				self.num_layers
										snake_case_ :							Any         =				min(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )
										snake_case_ :							Dict         =				max(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE ) - min_num_layers
										snake_case_ :							Dict         =				"encoder" if num_encoder_layers > num_decoder_layers else "decoder"

										for _ in range(_SCREAMING_SNAKE_CASE ):
												common_inputs["past_key_values"].append(
												    (
												        torch.zeros(_SCREAMING_SNAKE_CASE ),
												        torch.zeros(_SCREAMING_SNAKE_CASE ),
												        torch.zeros(_SCREAMING_SNAKE_CASE ),
												        torch.zeros(_SCREAMING_SNAKE_CASE ),
												    ) )
										# TODO: test this.
										snake_case_ :							Optional[int]         =				encoder_shape if remaining_side_name == "encoder" else decoder_shape
										for _ in range(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE ):
												common_inputs["past_key_values"].append((torch.zeros(_SCREAMING_SNAKE_CASE ), torch.zeros(_SCREAMING_SNAKE_CASE )) )
								return common_inputs






						def 					_lowerCAmelCase				(		self						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE = -1						, _SCREAMING_SNAKE_CASE = -1						, _SCREAMING_SNAKE_CASE = False						, _SCREAMING_SNAKE_CASE = None						, )       -> Mapping[str, Any]:
								snake_case_ :							Union[str, Any]         =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
								    _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )

								if self.use_past:
										if not is_torch_available():
												raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed." )
										else:
												import torch
										snake_case_       ,				snake_case_ :							List[str]         =				common_inputs["input_ids"].shape
										# Not using the same length for past_key_values
										snake_case_ :							Union[str, Any]         =				seqlen + 2
										snake_case_       ,				snake_case_ :							Any         =				self.num_layers
										snake_case_       ,				snake_case_ :							Optional[Any]         =				self.num_attention_heads
										snake_case_ :							Optional[int]         =				(
										    batch,
										    num_encoder_attention_heads,
										    past_key_values_length,
										    self._config.hidden_size // num_encoder_attention_heads,
										)

										snake_case_ :							str         =				common_inputs["attention_mask"].dtype
										snake_case_ :							Union[str, Any]         =				torch.cat(
										    [common_inputs["attention_mask"], torch.ones(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, dtype=_SCREAMING_SNAKE_CASE )]						, dim=1 )
										snake_case_ :							Optional[int]         =				[
										    (torch.zeros(_SCREAMING_SNAKE_CASE ), torch.zeros(_SCREAMING_SNAKE_CASE )) for _ in range(_SCREAMING_SNAKE_CASE )
										]
								return common_inputs






						def 					_lowerCAmelCase				(		self						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE = -1						, _SCREAMING_SNAKE_CASE = -1						, _SCREAMING_SNAKE_CASE = False						, _SCREAMING_SNAKE_CASE = None						, )       -> Mapping[str, Any]:
								# Copied from OnnxConfig.generate_dummy_inputs
								# Did not use super(OnnxConfigWithPast, self).generate_dummy_inputs for code clarity.
								# If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
								snake_case_ :							List[str]         =				compute_effective_axis_dimension(
								    _SCREAMING_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
								snake_case_ :							Any         =				tokenizer.num_special_tokens_to_add(_SCREAMING_SNAKE_CASE )
								snake_case_ :							int         =				compute_effective_axis_dimension(
								    _SCREAMING_SNAKE_CASE						, fixed_dimension=OnnxConfig.default_fixed_sequence						, num_token_to_add=_SCREAMING_SNAKE_CASE )

								# Generate dummy inputs according to compute batch and sequence
								snake_case_ :							List[Any]         =				[" ".join([tokenizer.unk_token] ) * seq_length] * batch_size
								snake_case_ :							Tuple         =				dict(tokenizer(_SCREAMING_SNAKE_CASE						, return_tensors=_SCREAMING_SNAKE_CASE ) )
								return common_inputs






						def 					_lowerCAmelCase				(		self						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE = -1						, _SCREAMING_SNAKE_CASE = -1						, _SCREAMING_SNAKE_CASE = False						, _SCREAMING_SNAKE_CASE = None						, )       -> Mapping[str, Any]:
								if self.task in ["default", "seq2seq-lm"]:
										snake_case_ :							List[Any]         =				self._generate_dummy_inputs_for_default_and_seqaseq_lm(
										    _SCREAMING_SNAKE_CASE						, batch_size=_SCREAMING_SNAKE_CASE						, seq_length=_SCREAMING_SNAKE_CASE						, is_pair=_SCREAMING_SNAKE_CASE						, framework=_SCREAMING_SNAKE_CASE )

								elif self.task == "causal-lm":
										snake_case_ :							Optional[Any]         =				self._generate_dummy_inputs_for_causal_lm(
										    _SCREAMING_SNAKE_CASE						, batch_size=_SCREAMING_SNAKE_CASE						, seq_length=_SCREAMING_SNAKE_CASE						, is_pair=_SCREAMING_SNAKE_CASE						, framework=_SCREAMING_SNAKE_CASE )
								else:
										snake_case_ :							Any         =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
										    _SCREAMING_SNAKE_CASE						, batch_size=_SCREAMING_SNAKE_CASE						, seq_length=_SCREAMING_SNAKE_CASE						, is_pair=_SCREAMING_SNAKE_CASE						, framework=_SCREAMING_SNAKE_CASE )

								return common_inputs






						def 					_lowerCAmelCase				(		self						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )       -> Any:
								if self.task in ["default", "seq2seq-lm"]:
										snake_case_ :							int         =				super()._flatten_past_key_values_(_SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )
								else:
										snake_case_ :							Optional[Any]         =				super(_SCREAMING_SNAKE_CASE						, self )._flatten_past_key_values_(
										    _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE						, _SCREAMING_SNAKE_CASE )
