
import math
import warnings
from dataclasses import dataclass
from typing import List, Optional, Tuple, Union

import numpy as np
import torch
from scipy import integrate

from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin







@dataclass
# Copied from diffusers.schedulers.scheduling_ddpm.DDPMSchedulerOutput with DDPM->LMSDiscrete
class      lowerCamelCase		(  A_  ):
     UpperCAmelCase__				:							torch.FloatTensor
     UpperCAmelCase__				:							Optional[torch.FloatTensor]           =		None



def 						lowercase_			(   A__ ,		A__=0.999 ,		A__="cosine" ,		)							->							Any:
    """simple docstring"""

    if alpha_transform_type == "cosine":

        def alpha_bar_fn(A__		):
            return math.cos((t + 0.008) / 1.008 * math.pi / 2		) ** 2

    elif alpha_transform_type == "exp":

        def alpha_bar_fn(A__		):
            return math.exp(t * -12.0		)

    else:
        raise ValueError(F'Unsupported alpha_tranform_type: {alpha_transform_type}'		)

    snake_case      =					[]
    for i in range(A__		):
        snake_case      =					i / num_diffusion_timesteps
        snake_case      =					(i + 1) / num_diffusion_timesteps
        betas.append(min(1 - alpha_bar_fn(A__		) / alpha_bar_fn(A__		) ,		A__		)		)
    return torch.tensor(A__ ,		dtype=torch.floataa		)







class      lowerCamelCase		(  A_							, A_  ):
     UpperCAmelCase__				:							Union[str, Any]           =		[e.name for e in KarrasDiffusionSchedulers]
     UpperCAmelCase__				:							List[Any]           =		1





     @register_to_config
     def __init__(self      :    Dict				,    _A      :    int = 1_0_0_0				,    _A      :    float = 0.00_01				,    _A      :    float = 0.02				,    _A      :    str = "linear"				,    _A      :    Optional[Union[np.ndarray, List[float]]] = None				,    _A      :    Optional[bool] = False				,    _A      :    str = "epsilon"				,    _A      :    str = "linspace"				,    _A      :    int = 0				,    )						->						Any:
         if trained_betas is not None:
             snake_case      =					torch.tensor(_A				,    dtype=torch.floataa   )
         elif beta_schedule == "linear":
             snake_case      =					torch.linspace(_A				,    _A				,    _A				,    dtype=torch.floataa   )
         elif beta_schedule == "scaled_linear":
             # this schedule is very specific to the latent diffusion model.
             snake_case      =					(
                 torch.linspace(beta_start**0.5				,    beta_end**0.5				,    _A				,    dtype=torch.floataa   ) ** 2
             )
         elif beta_schedule == "squaredcos_cap_v2":
             # Glide cosine schedule
             snake_case      =					betas_for_alpha_bar(_A   )
         else:
             raise NotImplementedError(f'{beta_schedule} does is not implemented for {self.__class__}'   )

         snake_case      =					1.0 - self.betas
         snake_case      =					torch.cumprod(self.alphas				,    dim=0   )

         snake_case      =					np.array(((1 - self.alphas_cumprod) / self.alphas_cumprod) ** 0.5   )
         snake_case      =					np.concatenate([sigmas[::-1], [0.0]]   ).astype(np.floataa   )
         snake_case      =					torch.from_numpy(_A   )

         # setable values
         snake_case      =					None
         snake_case      =					use_karras_sigmas
         self.set_timesteps(_A				,    _A   )
         snake_case      =					[]
         snake_case      =					False





     @property
     def 		UpperCAmelCase(self      :    Optional[Any]   )						->						Tuple:
         # standard deviation of the initial noise distribution
         if self.config.timestep_spacing in ["linspace", "trailing"]:
             return self.sigmas.max()

         return (self.sigmas.max() ** 2 + 1) ** 0.5





     def 		UpperCAmelCase(self      :    Tuple				,    _A      :    torch.FloatTensor				,    _A      :    Union[float, torch.FloatTensor]   )						->						torch.FloatTensor:
         if isinstance(_A				,    torch.Tensor   ):
             snake_case      =					timestep.to(self.timesteps.device   )
         snake_case      =					(self.timesteps == timestep).nonzero().item()
         snake_case      =					self.sigmas[step_index]
         snake_case      =					sample / ((sigma**2 + 1) ** 0.5)
         snake_case      =					True
         return sample





     def 		UpperCAmelCase(self      :    Union[str, Any]				,    _A      :    Tuple				,    _A      :    int				,    _A      :    str   )						->						str:

         def lms_derivative(_A      :    List[str]   ):
             snake_case      =					1.0
             for k in range(_A   ):
                 if current_order == k:
                     continue
                 prod *= (tau - self.sigmas[t - k]) / (self.sigmas[t - current_order] - self.sigmas[t - k])
             return prod

         snake_case      =					integrate.quad(_A				,    self.sigmas[t]				,    self.sigmas[t + 1]				,    epsrel=1E-4   )[0]

         return integrated_coeff





     def 		UpperCAmelCase(self      :    Optional[Any]				,    _A      :    int				,    _A      :    Union[str, torch.device] = None   )						->						Tuple:
         snake_case      =					num_inference_steps

         # "linspace", "leading", "trailing" corresponds to annotation of Table 2. of https://arxiv.org/abs/2305.08891
         if self.config.timestep_spacing == "linspace":
             snake_case      =					np.linspace(0				,    self.config.num_train_timesteps - 1				,    _A				,    dtype=_A   )[
                 ::-1
             ].copy()
         elif self.config.timestep_spacing == "leading":
             snake_case      =					self.config.num_train_timesteps // self.num_inference_steps
             # creates integer timesteps by multiplying by ratio
             # casting to int to avoid issues when num_inference_step is power of 3
             snake_case      =					(np.arange(0				,    _A   ) * step_ratio).round()[::-1].copy().astype(_A   )
             timesteps += self.config.steps_offset
         elif self.config.timestep_spacing == "trailing":
             snake_case      =					self.config.num_train_timesteps / self.num_inference_steps
             # creates integer timesteps by multiplying by ratio
             # casting to int to avoid issues when num_inference_step is power of 3
             snake_case      =					(np.arange(self.config.num_train_timesteps				,    0				,    -step_ratio   )).round().copy().astype(_A   )
             timesteps -= 1
         else:
             raise ValueError(
                 f'{self.config.timestep_spacing} is not supported. Please make sure to choose one of \'linspace\', \'leading\' or \'trailing\'.'   )

         snake_case      =					np.array(((1 - self.alphas_cumprod) / self.alphas_cumprod) ** 0.5   )
         snake_case      =					np.log(_A   )
         snake_case      =					np.interp(_A				,    np.arange(0				,    len(_A   )   )				,    _A   )

         if self.use_karras_sigmas:
             snake_case      =					self._convert_to_karras(in_sigmas=_A   )
             snake_case      =					np.array([self._sigma_to_t(_A				,    _A   ) for sigma in sigmas]   )

         snake_case      =					np.concatenate([sigmas, [0.0]]   ).astype(np.floataa   )

         snake_case      =					torch.from_numpy(_A   ).to(device=_A   )
         if str(_A   ).startswith("mps"   ):
             # mps does not support float64
             snake_case      =					torch.from_numpy(_A   ).to(_A				,    dtype=torch.floataa   )
         else:
             snake_case      =					torch.from_numpy(_A   ).to(device=_A   )

         snake_case      =					[]





     def 		UpperCAmelCase(self      :    Tuple				,    _A      :    Dict				,    _A      :    Any   )						->						Optional[Any]:
         # get log sigma
         snake_case      =					np.log(_A   )

         # get distribution
         snake_case      =					log_sigma - log_sigmas[:, np.newaxis]

         # get sigmas range
         snake_case      =					np.cumsum((dists >= 0)				,    axis=0   ).argmax(axis=0   ).clip(max=log_sigmas.shape[0] - 2   )
         snake_case      =					low_idx + 1

         snake_case      =					log_sigmas[low_idx]
         snake_case      =					log_sigmas[high_idx]

         # interpolate sigmas
         snake_case      =					(low - log_sigma) / (low - high)
         snake_case      =					np.clip(_A				,    0				,    1   )

         # transform interpolation to time range
         snake_case      =					(1 - w) * low_idx + w * high_idx
         snake_case      =					t.reshape(sigma.shape   )
         return t





     def 		UpperCAmelCase(self      :    int				,    _A      :    torch.FloatTensor   )						->						torch.FloatTensor:
         snake_case      =					in_sigmas[-1].item()
         snake_case      =					in_sigmas[0].item()

         snake_case      =					7.0  # 7.0 is the value used in the paper
         snake_case      =					np.linspace(0				,    1				,    self.num_inference_steps   )
         snake_case      =					sigma_min ** (1 / rho)
         snake_case      =					sigma_max ** (1 / rho)
         snake_case      =					(max_inv_rho + ramp * (min_inv_rho - max_inv_rho)) ** rho
         return sigmas





     def 		UpperCAmelCase(self      :    Tuple				,    _A      :    torch.FloatTensor				,    _A      :    Union[float, torch.FloatTensor]				,    _A      :    torch.FloatTensor				,    _A      :    int = 4				,    _A      :    bool = True				,    )						->						Union[LMSDiscreteSchedulerOutput, Tuple]:
         if not self.is_scale_input_called:
             warnings.warn(
                 "The `scale_model_input` function should be called before `step` to ensure correct denoising. "
                 "See `StableDiffusionPipeline` for a usage example."   )

         if isinstance(_A				,    torch.Tensor   ):
             snake_case      =					timestep.to(self.timesteps.device   )
         snake_case      =					(self.timesteps == timestep).nonzero().item()
         snake_case      =					self.sigmas[step_index]

         # 1. compute predicted original sample (x_0) from sigma-scaled predicted noise
         if self.config.prediction_type == "epsilon":
             snake_case      =					sample - sigma * model_output
         elif self.config.prediction_type == "v_prediction":
             # * c_out + input * c_skip
             snake_case      =					model_output * (-sigma / (sigma**2 + 1) ** 0.5) + (sample / (sigma**2 + 1))
         elif self.config.prediction_type == "sample":
             snake_case      =					model_output
         else:
             raise ValueError(
                 f'prediction_type given as {self.config.prediction_type} must be one of `epsilon`, or `v_prediction`'   )

         # 2. Convert to an ODE derivative
         snake_case      =					(sample - pred_original_sample) / sigma
         self.derivatives.append(_A   )
         if len(self.derivatives   ) > order:
             self.derivatives.pop(0   )

         # 3. Compute linear multistep coefficients
         snake_case      =					min(step_index + 1				,    _A   )
         snake_case      =					[self.get_lms_coefficient(_A				,    _A				,    _A   ) for curr_order in range(_A   )]

         # 4. Compute previous sample based on the derivatives path
         snake_case      =					sample + sum(
             coeff * derivative for coeff, derivative in zip(_A				,    reversed(self.derivatives   )   )   )

         if not return_dict:
             return (prev_sample,)

         return LMSDiscreteSchedulerOutput(prev_sample=_A				,    pred_original_sample=_A   )





     def 		UpperCAmelCase(self      :    str				,    _A      :    torch.FloatTensor				,    _A      :    torch.FloatTensor				,    _A      :    torch.FloatTensor				,    )						->						torch.FloatTensor:
         # Make sure sigmas and timesteps have the same device and dtype as original_samples
         snake_case      =					self.sigmas.to(device=original_samples.device				,    dtype=original_samples.dtype   )
         if original_samples.device.type == "mps" and torch.is_floating_point(_A   ):
             # mps does not support float64
             snake_case      =					self.timesteps.to(original_samples.device				,    dtype=torch.floataa   )
             snake_case      =					timesteps.to(original_samples.device				,    dtype=torch.floataa   )
         else:
             snake_case      =					self.timesteps.to(original_samples.device   )
             snake_case      =					timesteps.to(original_samples.device   )

         snake_case      =					[(schedule_timesteps == t).nonzero().item() for t in timesteps]

         snake_case      =					sigmas[step_indices].flatten()
         while len(sigma.shape   ) < len(original_samples.shape   ):
             snake_case      =					sigma.unsqueeze(-1   )

         snake_case      =					original_samples + noise * sigma
         return noisy_samples





     def __len__(self      :    Dict   )						->						Optional[int]:
         return self.config.num_train_timesteps



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  					= logging.get_logger(__name__)

_A  					= {
    "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      lowerCamelCase		(  A_  ):
     UpperCAmelCase__				:							List[Any]           =		"bigbird_pegasus"
     UpperCAmelCase__				:							Tuple           =		["past_key_values"]
     UpperCAmelCase__				:							Optional[Any]           =		{
         "num_attention_heads": "encoder_attention_heads",
         "hidden_size": "d_model",
         "attention_probs_dropout_prob": "attention_dropout",
     }





     def __init__(self      :    Any				,    _A      :    List[str]=9_6_1_0_3				,    _A      :    List[Any]=4_0_9_6				,    _A      :    str=1_6				,    _A      :    Tuple=4_0_9_6				,    _A      :    List[str]=1_6				,    _A      :    Optional[int]=1_6				,    _A      :    List[Any]=4_0_9_6				,    _A      :    Dict=1_6				,    _A      :    Tuple=0.0				,    _A      :    List[str]=0.0				,    _A      :    Dict=True				,    _A      :    int=True				,    _A      :    List[Any]="gelu_new"				,    _A      :    int=1_0_2_4				,    _A      :    int=0.1				,    _A      :    List[Any]=0.0				,    _A      :    Optional[int]=0.0				,    _A      :    Any=0.02				,    _A      :    Dict=2				,    _A      :    List[Any]=0.0				,    _A      :    Any=True				,    _A      :    str=0				,    _A      :    Dict=2				,    _A      :    Any=1				,    _A      :    List[str]="block_sparse"				,    _A      :    int=6_4				,    _A      :    Optional[int]=3				,    _A      :    List[Any]=False				,    **_A      :    Tuple				,    )						->						Any:
         snake_case      =					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      =					classifier_dropout
         snake_case      =					use_cache
         snake_case      =					encoder_layers
         snake_case      =					scale_embedding  # scale factor will be sqrt(d_model) if True

         # extra config
         snake_case      =					attention_type
         snake_case      =					block_size
         snake_case      =					num_random_blocks
         snake_case      =					use_bias

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







class      lowerCamelCase		(  A_  ):





     @property
     def 		UpperCAmelCase(self      :    Any   )						->						Mapping[str, Mapping[int, str]]:
         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_(_A				,    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(_A   ):
                     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
     def 		UpperCAmelCase(self      :    str   )						->						Mapping[str, Mapping[int, str]]:
         if self.task in ["default", "seq2seq-lm"]:
             snake_case      =					super().outputs
         else:
             snake_case      =					super(_A				,    self   ).outputs
             if self.use_past:
                 snake_case     ,							snake_case      =					self.num_layers
                 for i in range(_A   ):
                     snake_case      =					{0: "batch", 2: "past_sequence + sequence"}
                     snake_case      =					{0: "batch", 2: "past_sequence + sequence"}
         return common_outputs





     def 		UpperCAmelCase(self      :    Any				,    _A      :    PreTrainedTokenizer				,    _A      :    int = -1				,    _A      :    int = -1				,    _A      :    bool = False				,    _A      :    Optional[TensorType] = None				,    )						->						Mapping[str, Any]:
         snake_case      =					self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
             _A				,    _A				,    _A				,    _A				,    _A   )

         # Generate decoder inputs
         snake_case      =					seq_length if not self.use_past else 1
         snake_case      =					self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
             _A				,    _A				,    _A				,    _A				,    _A   )
         snake_case      =					{f'decoder_{name}': tensor for name, tensor in decoder_inputs.items()}
         snake_case      =					dict(**_A				,    **_A   )

         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(_A				,    _A   )]				,    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(_A				,    _A   )
             snake_case      =					max(_A				,    _A   ) - min_num_layers
             snake_case      =					"encoder" if num_encoder_layers > num_decoder_layers else "decoder"

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





     def 		UpperCAmelCase(self      :    Tuple				,    _A      :    PreTrainedTokenizer				,    _A      :    int = -1				,    _A      :    int = -1				,    _A      :    bool = False				,    _A      :    Optional[TensorType] = None				,    )						->						Mapping[str, Any]:
         snake_case      =					self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
             _A				,    _A				,    _A				,    _A				,    _A   )

         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(_A				,    _A				,    dtype=_A   )]				,    dim=1   )
             snake_case      =					[
                 (torch.zeros(_A   ), torch.zeros(_A   )) for _ in range(_A   )
             ]
         return common_inputs





     def 		UpperCAmelCase(self      :    Dict				,    _A      :    PreTrainedTokenizer				,    _A      :    int = -1				,    _A      :    int = -1				,    _A      :    bool = False				,    _A      :    Optional[TensorType] = 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      =					compute_effective_axis_dimension(
             _A				,    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(_A   )
         snake_case      =					compute_effective_axis_dimension(
             _A				,    fixed_dimension=OnnxConfig.default_fixed_sequence				,    num_token_to_add=_A   )

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





     def 		UpperCAmelCase(self      :    Any				,    _A      :    PreTrainedTokenizer				,    _A      :    int = -1				,    _A      :    int = -1				,    _A      :    bool = False				,    _A      :    Optional[TensorType] = None				,    )						->						Mapping[str, Any]:
         if self.task in ["default", "seq2seq-lm"]:
             snake_case      =					self._generate_dummy_inputs_for_default_and_seqaseq_lm(
                 _A				,    batch_size=_A				,    seq_length=_A				,    is_pair=_A				,    framework=_A   )

         elif self.task == "causal-lm":
             snake_case      =					self._generate_dummy_inputs_for_causal_lm(
                 _A				,    batch_size=_A				,    seq_length=_A				,    is_pair=_A				,    framework=_A   )
         else:
             snake_case      =					self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                 _A				,    batch_size=_A				,    seq_length=_A				,    is_pair=_A				,    framework=_A   )

         return common_inputs





     def 		UpperCAmelCase(self      :    List[Any]				,    _A      :    str				,    _A      :    Union[str, Any]				,    _A      :    Tuple				,    _A      :    List[Any]   )						->						Any:
         if self.task in ["default", "seq2seq-lm"]:
             snake_case      =					super()._flatten_past_key_values_(_A				,    _A				,    _A				,    _A   )
         else:
             snake_case      =					super(_A				,    self   )._flatten_past_key_values_(
                 _A				,    _A				,    _A				,    _A   )

