





import gc
import random
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

import diffusers
from diffusers import (
    AutoencoderKL,
    EulerDiscreteScheduler,
    StableDiffusionLatentUpscalePipeline,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.schedulers import KarrasDiffusionSchedulers
from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu

from ..pipeline_params import TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS, TEXT_GUIDED_IMAGE_VARIATION_PARAMS
from ..test_pipelines_common import PipelineKarrasSchedulerTesterMixin, PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()




def 		lowerCAmelCase_    (  __UpperCAmelCase:			Dict      )      ->	List[Any]:
    UpperCamelCase__							:				Any          =      [tensor.shape for tensor in tensor_list]
    return all(shape == shapes[0] for shape in shapes[1:]      )






class     lowercase__       (	_lowerCamelCase			,				_lowerCamelCase			,				_lowerCamelCase			,				unittest.TestCase				):

   '''simple docstring'''


   a						:							str   		=		StableDiffusionLatentUpscalePipeline
   a						:							Union[str, Any]   		=		TEXT_GUIDED_IMAGE_VARIATION_PARAMS - {
       "height",
       "width",
       "cross_attention_kwargs",
       "negative_prompt_embeds",
       "prompt_embeds",
   }
   a						:							Optional[Any]   		=		PipelineTesterMixin.required_optional_params - {"num_images_per_prompt"}
   a						:							Optional[Any]   		=		TEXT_GUIDED_IMAGE_VARIATION_BATCH_PARAMS
   a						:							str   		=		frozenset(
       []				)  # TO-DO: update image_params once pipeline is refactored with VaeImageProcessor.preprocess
   a						:							Union[str, Any]   		=		frozenset([]				)

   a						:							Tuple   		=		True




   @property
   def       UpperCamelCase__  (    self							) ->      List[str]:






       """simple docstring"""
       UpperCamelCase__							:				Optional[Any]          =      1
       UpperCamelCase__							:				Optional[int]          =      4
       UpperCamelCase__							:				List[Any]          =      (16, 16)

       UpperCamelCase__							:				List[Any]          =      floats_tensor((batch_size, num_channels) + sizes,		rng=random.Random(0							)							).to(lowercase_							)
       return image




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






       """simple docstring"""
       torch.manual_seed(0							)
       UpperCamelCase__							:				Optional[Any]          =      UNetaDConditionModel(
           act_fn='''gelu''',		attention_head_dim=8,		norm_num_groups=lowercase_,		block_out_channels=[32, 32, 64, 64],		time_cond_proj_dim=160,		conv_in_kernel=1,		conv_out_kernel=1,		cross_attention_dim=32,		down_block_types=(
               '''KDownBlock2D''',
               '''KCrossAttnDownBlock2D''',
               '''KCrossAttnDownBlock2D''',
               '''KCrossAttnDownBlock2D''',
           ),		in_channels=8,		mid_block_type=lowercase_,		only_cross_attention=lowercase_,		out_channels=5,		resnet_time_scale_shift='''scale_shift''',		time_embedding_type='''fourier''',		timestep_post_act='''gelu''',		up_block_types=('''KCrossAttnUpBlock2D''', '''KCrossAttnUpBlock2D''', '''KCrossAttnUpBlock2D''', '''KUpBlock2D'''),		)
       UpperCamelCase__							:				str          =      AutoencoderKL(
           block_out_channels=[32, 32, 64, 64],		in_channels=3,		out_channels=3,		down_block_types=[
               '''DownEncoderBlock2D''',
               '''DownEncoderBlock2D''',
               '''DownEncoderBlock2D''',
               '''DownEncoderBlock2D''',
           ],		up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D''', '''UpDecoderBlock2D''', '''UpDecoderBlock2D'''],		latent_channels=4,		)
       UpperCamelCase__							:				Union[str, Any]          =      EulerDiscreteScheduler(prediction_type='''sample'''							)
       UpperCamelCase__							:				str          =      CLIPTextConfig(
           bos_token_id=0,		eos_token_id=2,		hidden_size=32,		intermediate_size=37,		layer_norm_eps=1E-05,		num_attention_heads=4,		num_hidden_layers=5,		pad_token_id=1,		vocab_size=1000,		hidden_act='''quick_gelu''',		projection_dim=512,		)
       UpperCamelCase__							:				Optional[Any]          =      CLIPTextModel(lowercase_							)
       UpperCamelCase__							:				str          =      CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''							)

       UpperCamelCase__							:				Union[str, Any]          =      {
           '''unet''': model.eval(),
           '''vae''': vae.eval(),
           '''scheduler''': scheduler,
           '''text_encoder''': text_encoder,
           '''tokenizer''': tokenizer,
       }

       return components




   def       UpperCamelCase__  (    self,		__magic_name__,		__magic_name__=0							) ->      Union[str, Any]:






       """simple docstring"""
       if str(lowercase_							).startswith('''mps'''							):
           UpperCamelCase__							:				str          =      torch.manual_seed(lowercase_							)
       else:
           UpperCamelCase__							:				Optional[int]          =      torch.Generator(device=lowercase_							).manual_seed(lowercase_							)
       UpperCamelCase__							:				Optional[int]          =      {
           '''prompt''': '''A painting of a squirrel eating a burger''',
           '''image''': self.dummy_image.cpu(),
           '''generator''': generator,
           '''num_inference_steps''': 2,
           '''output_type''': '''numpy''',
       }
       return inputs




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






       """simple docstring"""
       UpperCamelCase__							:				List[str]          =      '''cpu'''

       UpperCamelCase__							:				Optional[Any]          =      self.get_dummy_components()
       UpperCamelCase__							:				List[str]          =      self.pipeline_class(**lowercase_							)
       pipe.to(lowercase_							)
       pipe.set_progress_bar_config(disable=lowercase_							)

       UpperCamelCase__							:				int          =      self.get_dummy_inputs(lowercase_							)
       UpperCamelCase__							:				int          =      pipe(**lowercase_							).images
       UpperCamelCase__							:				Dict          =      image[0, -3:, -3:, -1]

       self.assertEqual(image.shape,		(1, 256, 256, 3)							)
       UpperCamelCase__							:				Optional[Any]          =      np.array(
           [0.4722_2412, 0.4192_1633, 0.4471_7434, 0.4687_4192, 0.4258_8258, 0.4615_0726, 0.467_7534, 0.4558_3832, 0.4857_9055]							)
       UpperCamelCase__							:				Optional[int]          =      np.abs(image_slice.flatten() - expected_slice							).max()
       self.assertLessEqual(lowercase_,		1E-3							)




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






       """simple docstring"""
       super().test_attention_slicing_forward_pass(expected_max_diff=7E-3							)




   def       UpperCamelCase__  (    self							) ->      str:






       """simple docstring"""
       super().test_cpu_offload_forward_pass(expected_max_diff=3E-3							)




   def       UpperCamelCase__  (    self							) ->      Tuple:






       """simple docstring"""
       super().test_dict_tuple_outputs_equivalent(expected_max_difference=3E-3							)




   def       UpperCamelCase__  (    self							) ->      str:






       """simple docstring"""
       super().test_inference_batch_single_identical(expected_max_diff=7E-3							)




   def       UpperCamelCase__  (    self							) ->      Dict:






       """simple docstring"""
       super().test_pt_np_pil_outputs_equivalent(expected_max_diff=3E-3							)




   def       UpperCamelCase__  (    self							) ->      int:






       """simple docstring"""
       super().test_save_load_local(expected_max_difference=3E-3							)




   def       UpperCamelCase__  (    self							) ->      List[str]:






       """simple docstring"""
       super().test_save_load_optional_components(expected_max_difference=3E-3							)




   def       UpperCamelCase__  (    self							) ->      str:






       """simple docstring"""
       UpperCamelCase__							:				Optional[Any]          =      [
           '''DDIMScheduler''',
           '''DDPMScheduler''',
           '''PNDMScheduler''',
           '''HeunDiscreteScheduler''',
           '''EulerAncestralDiscreteScheduler''',
           '''KDPM2DiscreteScheduler''',
           '''KDPM2AncestralDiscreteScheduler''',
           '''DPMSolverSDEScheduler''',
       ]
       UpperCamelCase__							:				int          =      self.get_dummy_components()
       UpperCamelCase__							:				Optional[Any]          =      self.pipeline_class(**lowercase_							)

       # make sure that PNDM does not need warm-up
       pipe.scheduler.register_to_config(skip_prk_steps=lowercase_							)

       pipe.to(lowercase_							)
       pipe.set_progress_bar_config(disable=lowercase_							)
       UpperCamelCase__							:				Optional[int]          =      self.get_dummy_inputs(lowercase_							)
       UpperCamelCase__							:				str          =      2

       UpperCamelCase__							:				Optional[Any]          =      []
       for scheduler_enum in KarrasDiffusionSchedulers:
           if scheduler_enum.name in skip_schedulers:
               # no sigma schedulers are not supported
               # no schedulers
               continue

           UpperCamelCase__							:				List[str]          =      getattr(lowercase_,		scheduler_enum.name							)
           UpperCamelCase__							:				List[str]          =      scheduler_cls.from_config(pipe.scheduler.config							)
           UpperCamelCase__							:				List[str]          =      pipe(**lowercase_							)[0]
           outputs.append(lowercase_							)

       assert check_same_shape(lowercase_							)






@require_torch_gpu
@slow
class     lowercase__       (	unittest.TestCase				):

   '''simple docstring'''


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






       """simple docstring"""
       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()




   def       UpperCamelCase__  (    self							) ->      int:






       """simple docstring"""
       UpperCamelCase__							:				List[Any]          =      torch.manual_seed(33							)

       UpperCamelCase__							:				Optional[Any]          =      StableDiffusionPipeline.from_pretrained('''CompVis/stable-diffusion-v1-4''',		torch_dtype=torch.floataa							)
       pipe.to('''cuda'''							)

       UpperCamelCase__							:				Any          =      StableDiffusionLatentUpscalePipeline.from_pretrained(
           '''stabilityai/sd-x2-latent-upscaler''',		torch_dtype=torch.floataa							)
       upscaler.to('''cuda'''							)

       UpperCamelCase__							:				str          =      '''a photo of an astronaut high resolution, unreal engine, ultra realistic'''

       UpperCamelCase__							:				List[Any]          =      pipe(lowercase_,		generator=lowercase_,		output_type='''latent'''							).images

       UpperCamelCase__							:				Any          =      upscaler(
           prompt=lowercase_,		image=lowercase_,		num_inference_steps=20,		guidance_scale=0,		generator=lowercase_,		output_type='''np''',		).images[0]

       UpperCamelCase__							:				int          =      load_numpy(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/astronaut_1024.npy'''							)
       assert np.abs((expected_image - image).mean()							) < 5E-2




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






       """simple docstring"""
       UpperCamelCase__							:				str          =      torch.manual_seed(33							)

       UpperCamelCase__							:				Dict          =      StableDiffusionLatentUpscalePipeline.from_pretrained(
           '''stabilityai/sd-x2-latent-upscaler''',		torch_dtype=torch.floataa							)
       upscaler.to('''cuda'''							)

       UpperCamelCase__							:				Union[str, Any]          =      '''the temple of fire by Ross Tran and Gerardo Dottori, oil on canvas'''

       UpperCamelCase__							:				Optional[int]          =      load_image(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/fire_temple_512.png'''							)

       UpperCamelCase__							:				Any          =      upscaler(
           prompt=lowercase_,		image=lowercase_,		num_inference_steps=20,		guidance_scale=0,		generator=lowercase_,		output_type='''np''',		).images[0]

       UpperCamelCase__							:				Dict          =      load_numpy(
           '''https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/latent-upscaler/fire_temple_1024.npy'''							)
       assert np.abs((expected_image - image).max()							) < 5E-2







'''simple docstring'''

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


a  :				Dict									=  logging.get_logger(__name__)

a  :				List[str]									=  {
    'Helsinki-NLP/opus-mt-en-de': 'https://huggingface.co/Helsinki-NLP/opus-mt-en-de/resolve/main/config.json',
    # See all Marian models at https://huggingface.co/models?filter=marian
}






class 						a				(   _lowerCamelCase     ):
				snake_case_      =		"marian"
				snake_case_      =		["past_key_values"]
				snake_case_      =		{"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}


				def __init__(		self    :					List[Any]       ,				lowercase_    :					Optional[Any]=5_8101       ,				lowercase_    :					Dict=None       ,				lowercase_    :					List[str]=1024       ,				lowercase_    :					Optional[Any]=12       ,				lowercase_    :					int=4096       ,				lowercase_    :					Any=16       ,				lowercase_    :					Optional[int]=12       ,				lowercase_    :					str=4096       ,				lowercase_    :					Union[str, Any]=16       ,				lowercase_    :					Dict=0.0       ,				lowercase_    :					Union[str, Any]=0.0       ,				lowercase_    :					Optional[Any]=True       ,				lowercase_    :					Union[str, Any]=True       ,				lowercase_    :					int="gelu"       ,				lowercase_    :					Dict=1024       ,				lowercase_    :					int=0.1       ,				lowercase_    :					Tuple=0.0       ,				lowercase_    :					Tuple=0.0       ,				lowercase_    :					Tuple=0.02       ,				lowercase_    :					int=5_8100       ,				lowercase_    :					Optional[Any]=False       ,				lowercase_    :					Any=5_8100       ,				lowercase_    :					Optional[int]=0       ,				lowercase_    :					Dict=0       ,				lowercase_    :					List[str]=True       ,				**lowercase_    :					Any       ,				):
									snake_case_									=				vocab_size
									snake_case_									=				decoder_vocab_size or vocab_size
									snake_case_									=				max_position_embeddings
									snake_case_									=				d_model
									snake_case_									=				encoder_ffn_dim
									snake_case_									=				encoder_layers
									snake_case_									=				encoder_attention_heads
									snake_case_									=				decoder_ffn_dim
									snake_case_									=				decoder_layers
									snake_case_									=				decoder_attention_heads
									snake_case_									=				dropout
									snake_case_									=				attention_dropout
									snake_case_									=				activation_dropout
									snake_case_									=				activation_function
									snake_case_									=				init_std
									snake_case_									=				encoder_layerdrop
									snake_case_									=				decoder_layerdrop
									snake_case_									=				use_cache
									snake_case_									=				encoder_layers
									snake_case_									=				scale_embedding  # scale factor will be sqrt(d_model) if True
									snake_case_									=				share_encoder_decoder_embeddings
									super().__init__(
									    pad_token_id=lowercase_       ,				eos_token_id=lowercase_       ,				is_encoder_decoder=lowercase_       ,				decoder_start_token_id=lowercase_       ,				forced_eos_token_id=lowercase_       ,				**lowercase_       ,				)







class 						a				(   _lowerCamelCase     ):


				@property
				# Copied from transformers.models.bart.configuration_bart.BartOnnxConfig.inputs
				def   A_ (		self    :					Union[str, Any]					):
									if self.task in ["default", "seq2seq-lm"]:
														snake_case_									=				OrderedDict(
														    [
														        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
														        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
														    ]					)

														if self.use_past:
																			snake_case_									=				{0: '''batch'''}
																			snake_case_									=				{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
														else:
																			snake_case_									=				{0: '''batch''', 1: '''decoder_sequence'''}
																			snake_case_									=				{0: '''batch''', 1: '''decoder_sequence'''}

														if self.use_past:
																			self.fill_with_past_key_values_(lowercase_       ,				direction='''inputs'''					)
									elif self.task == "causal-lm":
														# TODO: figure this case out.
														snake_case_									=				OrderedDict(
														    [
														        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
														        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
														    ]					)
														if self.use_past:
																			snake_case_			,snake_case_									=				self.num_layers
																			for i in range(lowercase_					):
																								snake_case_									=				{0: '''batch''', 2: '''past_sequence + sequence'''}
																								snake_case_									=				{0: '''batch''', 2: '''past_sequence + sequence'''}
									else:
														snake_case_									=				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
				# Copied from transformers.models.bart.configuration_bart.BartOnnxConfig.outputs
				def   A_ (		self    :					Dict					):
									if self.task in ["default", "seq2seq-lm"]:
														snake_case_									=				super().outputs
									else:
														snake_case_									=				super(lowercase_       ,				self					).outputs
														if self.use_past:
																			snake_case_			,snake_case_									=				self.num_layers
																			for i in range(lowercase_					):
																								snake_case_									=				{0: '''batch''', 2: '''past_sequence + sequence'''}
																								snake_case_									=				{0: '''batch''', 2: '''past_sequence + sequence'''}
									return common_outputs


				def   A_ (		self    :					Dict       ,				lowercase_    :					PreTrainedTokenizer       ,				lowercase_    :					int = -1       ,				lowercase_    :					int = -1       ,				lowercase_    :					bool = False       ,				lowercase_    :					Optional[TensorType] = None       ,				):
									snake_case_									=				self._generate_dummy_inputs_for_encoder_and_decoder(
									    lowercase_       ,				lowercase_       ,				lowercase_       ,				lowercase_       ,				lowercase_					)

									# Generate decoder inputs
									snake_case_									=				seq_length if not self.use_past else 1
									snake_case_									=				self._generate_dummy_inputs_for_encoder_and_decoder(
									    lowercase_       ,				lowercase_       ,				lowercase_       ,				lowercase_       ,				lowercase_					)
									snake_case_									=				{F"decoder_{name}": tensor for name, tensor in decoder_inputs.items()}
									snake_case_									=				dict(**lowercase_       ,				**lowercase_					)

									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_									=				common_inputs['''input_ids'''].shape
														snake_case_									=				common_inputs['''decoder_input_ids'''].shape[1]
														snake_case_			,snake_case_									=				self.num_attention_heads
														snake_case_									=				(
														    batch,
														    num_encoder_attention_heads,
														    encoder_seq_length,
														    self._config.hidden_size // num_encoder_attention_heads,
														)
														snake_case_									=				decoder_seq_length + 3
														snake_case_									=				(
														    batch,
														    num_decoder_attention_heads,
														    decoder_past_length,
														    self._config.hidden_size // num_decoder_attention_heads,
														)

														snake_case_									=				torch.cat(
														    [common_inputs['''decoder_attention_mask'''], torch.ones(lowercase_       ,				lowercase_					)]       ,				dim=1					)

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

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


				def   A_ (		self    :					Union[str, Any]       ,				lowercase_    :					PreTrainedTokenizer       ,				lowercase_    :					int = -1       ,				lowercase_    :					int = -1       ,				lowercase_    :					bool = False       ,				lowercase_    :					Optional[TensorType] = None       ,				):
									snake_case_									=				self._generate_dummy_inputs_for_encoder_and_decoder(
									    lowercase_       ,				lowercase_       ,				lowercase_       ,				lowercase_       ,				lowercase_					)

									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_									=				common_inputs['''input_ids'''].shape
														# Not using the same length for past_key_values
														snake_case_									=				seqlen + 2
														snake_case_			,snake_case_									=				self.num_layers
														snake_case_			,snake_case_									=				self.num_attention_heads
														snake_case_									=				(
														    batch,
														    num_encoder_attention_heads,
														    past_key_values_length,
														    self._config.hidden_size // num_encoder_attention_heads,
														)

														snake_case_									=				common_inputs['''attention_mask'''].dtype
														snake_case_									=				torch.cat(
														    [common_inputs['''attention_mask'''], torch.ones(lowercase_       ,				lowercase_       ,				dtype=lowercase_					)]       ,				dim=1					)
														snake_case_									=				[
														    (torch.zeros(lowercase_					), torch.zeros(lowercase_					)) for _ in range(lowercase_					)
														]
									return common_inputs


				def   A_ (		self    :					List[str]       ,				lowercase_    :					PreTrainedTokenizer       ,				lowercase_    :					int = -1       ,				lowercase_    :					int = -1       ,				lowercase_    :					bool = False       ,				lowercase_    :					Optional[TensorType] = None       ,				):
									# 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_									=				compute_effective_axis_dimension(
									    lowercase_       ,				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_									=				tokenizer.num_special_tokens_to_add(lowercase_					)
									snake_case_									=				compute_effective_axis_dimension(
									    lowercase_       ,				fixed_dimension=OnnxConfig.default_fixed_sequence       ,				num_token_to_add=lowercase_					)

									# Generate dummy inputs according to compute batch and sequence
									snake_case_									=				[''' '''.join([tokenizer.unk_token]					) * seq_length] * batch_size
									snake_case_									=				dict(tokenizer(lowercase_       ,				return_tensors=lowercase_					)					)
									return common_inputs


				def   A_ (		self    :					Any       ,				lowercase_    :					PreTrainedTokenizer       ,				lowercase_    :					int = -1       ,				lowercase_    :					int = -1       ,				lowercase_    :					bool = False       ,				lowercase_    :					Optional[TensorType] = None       ,				):
									if self.task in ["default", "seq2seq-lm"]:
														snake_case_									=				self._generate_dummy_inputs_for_default_and_seqaseq_lm(
														    lowercase_       ,				batch_size=lowercase_       ,				seq_length=lowercase_       ,				is_pair=lowercase_       ,				framework=lowercase_					)

									else:
														snake_case_									=				self._generate_dummy_inputs_for_causal_lm(
														    lowercase_       ,				batch_size=lowercase_       ,				seq_length=lowercase_       ,				is_pair=lowercase_       ,				framework=lowercase_					)

									return common_inputs


				def   A_ (		self    :					Dict       ,				lowercase_    :					List[str]       ,				lowercase_    :					List[str]       ,				lowercase_    :					int       ,				lowercase_    :					List[str]					):
									if self.task in ["default", "seq2seq-lm"]:
														snake_case_									=				super()._flatten_past_key_values_(lowercase_       ,				lowercase_       ,				lowercase_       ,				lowercase_					)
									else:
														snake_case_									=				super(lowercase_       ,				self					)._flatten_past_key_values_(
														    lowercase_       ,				lowercase_       ,				lowercase_       ,				lowercase_					)


				@property
				def   A_ (		self    :					List[str]					):
									return 1e-4

