






import inspect
import unittest

from transformers import ViTHybridConfig
from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

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


if is_torch_available():
		import torch
		from torch import nn

		from transformers import ViTHybridForImageClassification, ViTHybridImageProcessor, ViTHybridModel
		from transformers.models.vit_hybrid.modeling_vit_hybrid import VIT_HYBRID_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
		from PIL import Image





class 	snake_case__ :
	def __init__(    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__=13      ,       lowerCAmelCase__=64      ,       lowerCAmelCase__=2      ,       lowerCAmelCase__=3      ,       lowerCAmelCase__=True      ,       lowerCAmelCase__=True      ,       lowerCAmelCase__=32      ,       lowerCAmelCase__=5      ,       lowerCAmelCase__=4      ,       lowerCAmelCase__=37      ,       lowerCAmelCase__="gelu"      ,       lowerCAmelCase__=0.1      ,       lowerCAmelCase__=0.1      ,       lowerCAmelCase__=10      ,       lowerCAmelCase__=0.0_2      ,       lowerCAmelCase__=[1, 16, 4, 4]      ,       lowerCAmelCase__=None      ,       )							->				Union[str, Any]:
							__magic_name__      :       Union[str, Any]       						= parent
							__magic_name__      :       Any       						= batch_size
							__magic_name__      :       Optional[int]       						= image_size
							__magic_name__      :       int       						= patch_size
							__magic_name__      :       Tuple       						= num_channels
							__magic_name__      :       Tuple       						= is_training
							__magic_name__      :       Union[str, Any]       						= use_labels
							__magic_name__      :       str       						= hidden_size
							__magic_name__      :       Dict       						= num_hidden_layers
							__magic_name__      :       Optional[int]       						= num_attention_heads
							__magic_name__      :       int       						= intermediate_size
							__magic_name__      :       Optional[int]       						= hidden_act
							__magic_name__      :       Optional[Any]       						= hidden_dropout_prob
							__magic_name__      :       Tuple       						= attention_probs_dropout_prob
							__magic_name__      :       Union[str, Any]       						= type_sequence_label_size
							__magic_name__      :       Dict       						= initializer_range
							__magic_name__      :       Optional[int]       						= scope
							__magic_name__      :       Union[str, Any]       						= backbone_featmap_shape

							# in ViT hybrid, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
							# the number of patches is based on the feature map of the backbone, which by default uses an output stride
							# of 32, which means that the feature map has a spatial resolution of 1/32 of the input image size
							__magic_name__      :       List[Any]       						= (self.image_size // 32) ** 2
							__magic_name__      :       str       						= num_patches + 1
	def       __magic_name__    (    self			)							->				Any:
							__magic_name__      :       Any       						= floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]			)

							__magic_name__      :       int       						= None
							if self.use_labels:
													__magic_name__      :       Optional[int]       						= ids_tensor([self.batch_size]      ,       self.type_sequence_label_size			)

							__magic_name__      :       Optional[int]       						= self.get_config()

							return config, pixel_values, labels
	def       __magic_name__    (    self			)							->				Tuple:
							__magic_name__      :       List[str]       						= {
							    """global_padding""": """same""",
							    """layer_type""": """bottleneck""",
							    """depths""": [3, 4, 9],
							    """out_features""": ["""stage1""", """stage2""", """stage3"""],
							    """embedding_dynamic_padding""": True,
							    """hidden_sizes""": [4, 8, 16, 32],
							    """num_groups""": 2,
							}

							return ViTHybridConfig(
							    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=lowerCAmelCase__      ,       initializer_range=self.initializer_range      ,       backbone_featmap_shape=self.backbone_featmap_shape      ,       backbone_config=lowerCAmelCase__      ,       )
	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)							->				Any:
							__magic_name__      :       str       						= ViTHybridModel(config=lowerCAmelCase__			)
							model.to(lowerCAmelCase__			)
							model.eval()
							__magic_name__      :       Tuple       						= model(lowerCAmelCase__			)
							self.parent.assertEqual(result.last_hidden_state.shape      ,       (self.batch_size, self.seq_length, self.hidden_size)			)
	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)							->				Union[str, Any]:
							__magic_name__      :       Tuple       						= self.type_sequence_label_size
							__magic_name__      :       Dict       						= ViTHybridForImageClassification(lowerCAmelCase__			)
							model.to(lowerCAmelCase__			)
							model.eval()
							__magic_name__      :       str       						= model(lowerCAmelCase__      ,       labels=lowerCAmelCase__			)
							self.parent.assertEqual(result.logits.shape      ,       (self.batch_size, self.type_sequence_label_size)			)







	def       __magic_name__    (    self			)							->				str:
							__magic_name__      :       Optional[int]       						= self.prepare_config_and_inputs()
							__magic_name__						,__magic_name__						,__magic_name__      :       Optional[int]       						= config_and_inputs
							__magic_name__      :       List[str]       						= {"""pixel_values""": pixel_values}
							return config, inputs_dict





@require_torch
class 	snake_case__ (							_lowerCAmelCase						,  _lowerCAmelCase						,  unittest.TestCase				):
	lowercase__						:					Optional[int]											=   (ViTHybridModel, ViTHybridForImageClassification) if is_torch_available() else ()
	lowercase__						:					str											=   (
	    {'''feature-extraction''': ViTHybridModel, '''image-classification''': ViTHybridForImageClassification}
	    if is_torch_available()
	    else {}
	)
	lowercase__						:					List[Any]											=   False
	lowercase__						:					int											=   False
	lowercase__						:					Optional[Any]											=   False
	def       __magic_name__    (    self			)							->				Optional[Any]:
							__magic_name__      :       Optional[int]       						= ViTHybridModelTester(self			)
							__magic_name__      :       List[str]       						= ConfigTester(self      ,       config_class=lowerCAmelCase__      ,       has_text_modality=lowerCAmelCase__      ,       hidden_size=37			)
	def       __magic_name__    (    self			)							->				Tuple:
							self.config_tester.run_common_tests()
	@unittest.skip(reason="""ViT does not use inputs_embeds"""			)
	def       __magic_name__    (    self			)							->				Optional[int]:
							pass
	def       __magic_name__    (    self			)							->				Any:
							__magic_name__						,__magic_name__      :       Optional[Any]       						= self.model_tester.prepare_config_and_inputs_for_common()

							for model_class in self.all_model_classes:
													__magic_name__      :       List[str]       						= model_class(lowerCAmelCase__			)
													self.assertIsInstance(model.get_input_embeddings()      ,       (nn.Module)			)
													__magic_name__      :       Optional[int]       						= model.get_output_embeddings()
													self.assertTrue(x is None or isinstance(lowerCAmelCase__      ,       nn.Linear			)			)
	def       __magic_name__    (    self			)							->				int:
							__magic_name__						,__magic_name__      :       str       						= self.model_tester.prepare_config_and_inputs_for_common()

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

													__magic_name__      :       List[Any]       						= ["""pixel_values"""]
													self.assertListEqual(arg_names[:1]      ,       lowerCAmelCase__			)
	def       __magic_name__    (    self			)							->				str:
							__magic_name__      :       Optional[int]       						= self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_model(*lowerCAmelCase__			)
	def       __magic_name__    (    self			)							->				Tuple:
							__magic_name__      :       Dict       						= self.model_tester.prepare_config_and_inputs()
							self.model_tester.create_and_check_for_image_classification(*lowerCAmelCase__			)
	def       __magic_name__    (    self			)							->				List[Any]:
							__magic_name__						,__magic_name__      :       Tuple       						= self.model_tester.prepare_config_and_inputs_for_common()

							__magic_name__      :       List[str]       						= _config_zero_init(lowerCAmelCase__			)
							for model_class in self.all_model_classes:
													__magic_name__      :       Any       						= model_class(config=lowerCAmelCase__			)
													# Skip the check for the backbone
													for name, module in model.named_modules():
																			if module.__class__.__name__ == "ViTHybridPatchEmbeddings":
																									__magic_name__      :       Dict       						= [F'{name}.{key}' for key in module.state_dict().keys()]
																									break

													for name, param in model.named_parameters():
																			if param.requires_grad:
																									if name in backbone_params:
																															continue
																									self.assertIn(
																									    ((param.data.mean() * 1e9).round() / 1e9).item()      ,       [0.0, 1.0]      ,       msg=F'Parameter {name} of model {model_class} seems not properly initialized'      ,       )







	@slow
	def       __magic_name__    (    self			)							->				Dict:
							for model_name in VIT_HYBRID_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
													__magic_name__      :       List[Any]       						= ViTHybridModel.from_pretrained(lowerCAmelCase__			)
													self.assertIsNotNone(lowerCAmelCase__			)



def    UpperCamelCase						(	):






						"""simple docstring"""







						__magic_name__      :       Any       						= Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""			)
						return image





@require_torch
@require_vision
class 	snake_case__ (							unittest.TestCase				):
	@cached_property
	def       __magic_name__    (    self			)							->				List[str]:
							return (
							    ViTHybridImageProcessor.from_pretrained(VIT_HYBRID_PRETRAINED_MODEL_ARCHIVE_LIST[0]			)
							    if is_vision_available()
							    else None
							)
	@slow
	def       __magic_name__    (    self			)							->				List[str]:
							__magic_name__      :       int       						= ViTHybridForImageClassification.from_pretrained(VIT_HYBRID_PRETRAINED_MODEL_ARCHIVE_LIST[0]			).to(
							    lowerCAmelCase__			)

							__magic_name__      :       List[Any]       						= self.default_image_processor
							__magic_name__      :       str       						= prepare_img()
							__magic_name__      :       List[Any]       						= image_processor(images=lowerCAmelCase__      ,       return_tensors="""pt"""			).to(lowerCAmelCase__			)

							# forward pass
							with torch.no_grad():
													__magic_name__      :       Optional[int]       						= model(**lowerCAmelCase__			)

							# verify the logits
							__magic_name__      :       Tuple       						= torch.Size((1, 10_00)			)
							self.assertEqual(outputs.logits.shape      ,       lowerCAmelCase__			)

							__magic_name__      :       Any       						= torch.tensor([-1.9_0_9_0, -0.4_9_9_3, -0.2_3_8_9]			).to(lowerCAmelCase__			)

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







	@slow
	@require_accelerate
	def       __magic_name__    (    self			)							->				Union[str, Any]:
							__magic_name__      :       Dict       						= ViTHybridImageProcessor.from_pretrained("""google/vit-hybrid-base-bit-384"""			)
							__magic_name__      :       Any       						= ViTHybridForImageClassification.from_pretrained("""google/vit-hybrid-base-bit-384"""      ,       device_map="""auto"""			)

							__magic_name__      :       Any       						= prepare_img()

							__magic_name__      :       str       						= image_processor(images=lowerCAmelCase__      ,       return_tensors="""pt"""			)
							__magic_name__      :       str       						= model(**lowerCAmelCase__			)
							__magic_name__      :       List[Any]       						= outputs.logits
							# model predicts one of the 1000 ImageNet classes
							__magic_name__      :       Union[str, Any]       						= logits.argmax(-1			).item()

							self.assertTrue(model.config.idalabel[predicted_class_idx]      ,       """tabby, tabby cat"""			)








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

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


__magic_name__:					Any							=     logging.get_logger(__name__)

__magic_name__:					Dict							=     {
    "facebook/blenderbot_small-90M": "https://huggingface.co/facebook/blenderbot_small-90M/resolve/main/config.json",
    # See all BlenderbotSmall models at https://huggingface.co/models?filter=blenderbot_small
}





class 	snake_case__ (							_lowerCAmelCase				):
	lowercase__						:					Any											=   '''blenderbot-small'''
	lowercase__						:					Optional[int]											=   ['''past_key_values''']
	lowercase__						:					Dict											=   {'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}
	def __init__(    self      ,       lowerCAmelCase__=5_02_65      ,       lowerCAmelCase__=5_12      ,       lowerCAmelCase__=8      ,       lowerCAmelCase__=20_48      ,       lowerCAmelCase__=16      ,       lowerCAmelCase__=8      ,       lowerCAmelCase__=20_48      ,       lowerCAmelCase__=16      ,       lowerCAmelCase__=0.0      ,       lowerCAmelCase__=0.0      ,       lowerCAmelCase__=True      ,       lowerCAmelCase__=True      ,       lowerCAmelCase__="gelu"      ,       lowerCAmelCase__=5_12      ,       lowerCAmelCase__=0.1      ,       lowerCAmelCase__=0.0      ,       lowerCAmelCase__=0.0      ,       lowerCAmelCase__=0.0_2      ,       lowerCAmelCase__=1      ,       lowerCAmelCase__=False      ,       lowerCAmelCase__=0      ,       lowerCAmelCase__=1      ,       lowerCAmelCase__=2      ,       lowerCAmelCase__=2      ,       **lowerCAmelCase__      ,       )							->				Tuple:
							__magic_name__      :       Tuple       						= vocab_size
							__magic_name__      :       List[str]       						= max_position_embeddings
							__magic_name__      :       Union[str, Any]       						= d_model
							__magic_name__      :       Optional[int]       						= encoder_ffn_dim
							__magic_name__      :       Union[str, Any]       						= encoder_layers
							__magic_name__      :       List[str]       						= encoder_attention_heads
							__magic_name__      :       List[Any]       						= decoder_ffn_dim
							__magic_name__      :       str       						= decoder_layers
							__magic_name__      :       List[str]       						= decoder_attention_heads
							__magic_name__      :       Union[str, Any]       						= dropout
							__magic_name__      :       Tuple       						= attention_dropout
							__magic_name__      :       List[Any]       						= activation_dropout
							__magic_name__      :       List[Any]       						= activation_function
							__magic_name__      :       Optional[int]       						= init_std
							__magic_name__      :       Dict       						= encoder_layerdrop
							__magic_name__      :       Union[str, Any]       						= decoder_layerdrop
							__magic_name__      :       Optional[int]       						= use_cache
							__magic_name__      :       List[Any]       						= encoder_layers
							__magic_name__      :       Dict       						= scale_embedding  # scale factor will be sqrt(d_model) if True

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





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

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

													if self.use_past:
																			self.fill_with_past_key_values_(lowerCAmelCase__      ,       direction="""inputs"""			)
							elif self.task == "causal-lm":
													# TODO: figure this case out.
													__magic_name__      :       Union[str, Any]       						= OrderedDict(
													    [
													        ("""input_ids""", {0: """batch""", 1: """encoder_sequence"""}),
													        ("""attention_mask""", {0: """batch""", 1: """encoder_sequence"""}),
													    ]			)
													if self.use_past:
																			__magic_name__						,__magic_name__      :       Dict       						= self.num_layers
																			for i in range(lowerCAmelCase__			):
																									__magic_name__      :       Dict       						= {0: """batch""", 2: """past_sequence + sequence"""}
																									__magic_name__      :       int       						= {0: """batch""", 2: """past_sequence + sequence"""}
							else:
													__magic_name__      :       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       __magic_name__    (    self			)							->				Mapping[str, Mapping[int, str]]:
							if self.task in ["default", "seq2seq-lm"]:
													__magic_name__      :       Any       						= super().outputs
							else:
													__magic_name__      :       int       						= super(lowerCAmelCase__      ,       self			).outputs
													if self.use_past:
																			__magic_name__						,__magic_name__      :       str       						= self.num_layers
																			for i in range(lowerCAmelCase__			):
																									__magic_name__      :       Tuple       						= {0: """batch""", 2: """past_sequence + sequence"""}
																									__magic_name__      :       Dict       						= {0: """batch""", 2: """past_sequence + sequence"""}
							return common_outputs
	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__ = -1      ,       lowerCAmelCase__ = -1      ,       lowerCAmelCase__ = False      ,       lowerCAmelCase__ = None      ,       )							->				Mapping[str, Any]:
							__magic_name__      :       Tuple       						= self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
							    lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)

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

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

													__magic_name__      :       List[str]       						= torch.cat(
													    [common_inputs["""decoder_attention_mask"""], torch.ones(lowerCAmelCase__      ,       lowerCAmelCase__			)]      ,       dim=1			)

													__magic_name__      :       Union[str, Any]       						= []
													# If the number of encoder and decoder layers are present in the model configuration, both are considered
													__magic_name__						,__magic_name__      :       List[str]       						= self.num_layers
													__magic_name__      :       Optional[Any]       						= min(lowerCAmelCase__      ,       lowerCAmelCase__			)
													__magic_name__      :       List[str]       						= max(lowerCAmelCase__      ,       lowerCAmelCase__			) - min_num_layers
													__magic_name__      :       Tuple       						= """encoder""" if num_encoder_layers > num_decoder_layers else """decoder"""

													for _ in range(lowerCAmelCase__			):
																			common_inputs["past_key_values"].append(
																			    (
																			        torch.zeros(lowerCAmelCase__			),
																			        torch.zeros(lowerCAmelCase__			),
																			        torch.zeros(lowerCAmelCase__			),
																			        torch.zeros(lowerCAmelCase__			),
																			    )			)
													# TODO: test this.
													__magic_name__      :       Union[str, Any]       						= encoder_shape if remaining_side_name == """encoder""" else decoder_shape
													for _ in range(lowerCAmelCase__      ,       lowerCAmelCase__			):
																			common_inputs["past_key_values"].append((torch.zeros(lowerCAmelCase__			), torch.zeros(lowerCAmelCase__			))			)
							return common_inputs
	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__ = -1      ,       lowerCAmelCase__ = -1      ,       lowerCAmelCase__ = False      ,       lowerCAmelCase__ = None      ,       )							->				Mapping[str, Any]:
							__magic_name__      :       int       						= self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
							    lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)

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

													__magic_name__      :       Optional[int]       						= common_inputs["""attention_mask"""].dtype
													__magic_name__      :       Optional[Any]       						= torch.cat(
													    [common_inputs["""attention_mask"""], torch.ones(lowerCAmelCase__      ,       lowerCAmelCase__      ,       dtype=lowerCAmelCase__			)]      ,       dim=1			)
													__magic_name__      :       Tuple       						= [
													    (torch.zeros(lowerCAmelCase__			), torch.zeros(lowerCAmelCase__			)) for _ in range(lowerCAmelCase__			)
													]
							return common_inputs
	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__ = -1      ,       lowerCAmelCase__ = -1      ,       lowerCAmelCase__ = False      ,       lowerCAmelCase__ = 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
							__magic_name__      :       Tuple       						= compute_effective_axis_dimension(
							    lowerCAmelCase__      ,       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
							__magic_name__      :       str       						= tokenizer.num_special_tokens_to_add(lowerCAmelCase__			)
							__magic_name__      :       List[str]       						= compute_effective_axis_dimension(
							    lowerCAmelCase__      ,       fixed_dimension=OnnxConfig.default_fixed_sequence      ,       num_token_to_add=lowerCAmelCase__			)

							# Generate dummy inputs according to compute batch and sequence
							__magic_name__      :       List[Any]       						= [""" """.join([tokenizer.unk_token]			) * seq_length] * batch_size
							__magic_name__      :       List[str]       						= dict(tokenizer(lowerCAmelCase__      ,       return_tensors=lowerCAmelCase__			)			)
							return common_inputs
	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__ = -1      ,       lowerCAmelCase__ = -1      ,       lowerCAmelCase__ = False      ,       lowerCAmelCase__ = None      ,       )							->				Mapping[str, Any]:
							if self.task in ["default", "seq2seq-lm"]:
													__magic_name__      :       Tuple       						= self._generate_dummy_inputs_for_default_and_seqaseq_lm(
													    lowerCAmelCase__      ,       batch_size=lowerCAmelCase__      ,       seq_length=lowerCAmelCase__      ,       is_pair=lowerCAmelCase__      ,       framework=lowerCAmelCase__			)

							elif self.task == "causal-lm":
													__magic_name__      :       str       						= self._generate_dummy_inputs_for_causal_lm(
													    lowerCAmelCase__      ,       batch_size=lowerCAmelCase__      ,       seq_length=lowerCAmelCase__      ,       is_pair=lowerCAmelCase__      ,       framework=lowerCAmelCase__			)
							else:
													__magic_name__      :       Dict       						= self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
													    lowerCAmelCase__      ,       batch_size=lowerCAmelCase__      ,       seq_length=lowerCAmelCase__      ,       is_pair=lowerCAmelCase__      ,       framework=lowerCAmelCase__			)

							return common_inputs







	def       __magic_name__    (    self      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)							->				Dict:
							if self.task in ["default", "seq2seq-lm"]:
													__magic_name__      :       List[Any]       						= super()._flatten_past_key_values_(lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)
							else:
													__magic_name__      :       Tuple       						= super(lowerCAmelCase__      ,       self			)._flatten_past_key_values_(
													    lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__      ,       lowerCAmelCase__			)
