code: 
  
  """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  :					Optional[Any]												=	logging.get_logger(__name__)
  
  __A  :					Optional[Any]												=	{
      '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				(     lowerCAmelCase__		):
  						SCREAMING_SNAKE_CASE              =					"""bigbird_pegasus"""
  						SCREAMING_SNAKE_CASE              =					["""past_key_values"""]
  						SCREAMING_SNAKE_CASE              =					{
  						    """num_attention_heads""": """encoder_attention_heads""",
  						    """hidden_size""": """d_model""",
  						    """attention_probs_dropout_prob""": """attention_dropout""",
  						}
  
  
  						def __init__(self				:	List[Any]  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=9_6_1_0_3  ,  __SCREAMING_SNAKE_CASE				:	Tuple=4_0_9_6  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]=1_6  ,  __SCREAMING_SNAKE_CASE				:	Any=4_0_9_6  ,  __SCREAMING_SNAKE_CASE				:	int=1_6  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=1_6  ,  __SCREAMING_SNAKE_CASE				:	List[str]=4_0_9_6  ,  __SCREAMING_SNAKE_CASE				:	List[str]=1_6  ,  __SCREAMING_SNAKE_CASE				:	int=0.0  ,  __SCREAMING_SNAKE_CASE				:	str=0.0  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=True  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=True  ,  __SCREAMING_SNAKE_CASE				:	Any="gelu_new"  ,  __SCREAMING_SNAKE_CASE				:	str=1_0_2_4  ,  __SCREAMING_SNAKE_CASE				:	Tuple=0.1  ,  __SCREAMING_SNAKE_CASE				:	int=0.0  ,  __SCREAMING_SNAKE_CASE				:	str=0.0  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=0.0_2  ,  __SCREAMING_SNAKE_CASE				:	List[str]=2  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=0.0  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=True  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]=0  ,  __SCREAMING_SNAKE_CASE				:	List[str]=2  ,  __SCREAMING_SNAKE_CASE				:	Dict=1  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]="block_sparse"  ,  __SCREAMING_SNAKE_CASE				:	int=6_4  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=3  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=False  ,  **__SCREAMING_SNAKE_CASE				:	Dict  ,  ):
  											A    =      vocab_size
  											A    =      max_position_embeddings
  											A    =      d_model
  											A    =      encoder_ffn_dim
  											A    =      encoder_layers
  											A    =      encoder_attention_heads
  											A    =      decoder_ffn_dim
  											A    =      decoder_layers
  											A    =      decoder_attention_heads
  											A    =      dropout
  											A    =      attention_dropout
  											A    =      activation_dropout
  											A    =      activation_function
  											A    =      init_std
  											A    =      encoder_layerdrop
  											A    =      decoder_layerdrop
  											A    =      classifier_dropout
  											A    =      use_cache
  											A    =      encoder_layers
  											A    =      scale_embedding  # scale factor will be sqrt(d_model) if True
  
  											# extra config
  											A    =      attention_type
  											A    =      block_size
  											A    =      num_random_blocks
  											A    =      use_bias
  
  											super().__init__(
  											    pad_token_id=lowerCAmelCase_  ,  bos_token_id=lowerCAmelCase_  ,  eos_token_id=lowerCAmelCase_  ,  is_encoder_decoder=lowerCAmelCase_  ,  decoder_start_token_id=lowerCAmelCase_  ,  **lowerCAmelCase_  ,  )
  
  
  
  
  
  class     __UpperCamelCase				(     lowerCAmelCase__		):
  
  
  						@property
  						def       SCREAMING_SNAKE_CASE__     (self				:	List[Any]):
  
  
  
  
  
  
  											if self.task in ["default", "seq2seq-lm"]:
  																A    =      OrderedDict(
  																    [
  																        ("input_ids", {0: "batch", 1: "encoder_sequence"}),
  																        ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
  																    ])
  
  																if self.use_past:
  																					A    =      {0: "batch"}
  																					A    =      {0: "batch", 1: "past_decoder_sequence + sequence"}
  																else:
  																					A    =      {0: "batch", 1: "decoder_sequence"}
  																					A    =      {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.
  																A    =      OrderedDict(
  																    [
  																        ("input_ids", {0: "batch", 1: "encoder_sequence"}),
  																        ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
  																    ])
  																if self.use_past:
  																					A    ,					A    =      self.num_layers
  																					for i in range(lowerCAmelCase_):
  																										A    =      {0: "batch", 2: "past_sequence + sequence"}
  																										A    =      {0: "batch", 2: "past_sequence + sequence"}
  											else:
  																A    =      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       SCREAMING_SNAKE_CASE__     (self				:	Dict):
  
  
  
  
  
  
  											if self.task in ["default", "seq2seq-lm"]:
  																A    =      super().outputs
  											else:
  																A    =      super(lowerCAmelCase_  ,  self).outputs
  																if self.use_past:
  																					A    ,					A    =      self.num_layers
  																					for i in range(lowerCAmelCase_):
  																										A    =      {0: "batch", 2: "past_sequence + sequence"}
  																										A    =      {0: "batch", 2: "past_sequence + sequence"}
  											return common_outputs
  
  
  						def       SCREAMING_SNAKE_CASE__     (self				:	List[Any]  ,  __SCREAMING_SNAKE_CASE				:	PreTrainedTokenizer  ,  __SCREAMING_SNAKE_CASE				:	int = -1  ,  __SCREAMING_SNAKE_CASE				:	int = -1  ,  __SCREAMING_SNAKE_CASE				:	bool = False  ,  __SCREAMING_SNAKE_CASE				:	Optional[TensorType] = None  ,  ):
  											A    =      self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
  											    lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_)
  
  											# Generate decoder inputs
  											A    =      seq_length if not self.use_past else 1
  											A    =      self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
  											    lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_)
  											A    =      {F"""decoder_{name}""": tensor for name, tensor in decoder_inputs.items()}
  											A    =      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
  																A    ,					A    =      common_inputs["input_ids"].shape
  																A    =      common_inputs["decoder_input_ids"].shape[1]
  																A    ,					A    =      self.num_attention_heads
  																A    =      (
  																    batch,
  																    num_encoder_attention_heads,
  																    encoder_seq_length,
  																    self._config.hidden_size // num_encoder_attention_heads,
  																)
  																A    =      decoder_seq_length + 3
  																A    =      (
  																    batch,
  																    num_decoder_attention_heads,
  																    decoder_past_length,
  																    self._config.hidden_size // num_decoder_attention_heads,
  																)
  
  																A    =      torch.cat(
  																    [common_inputs["decoder_attention_mask"], torch.ones(lowerCAmelCase_  ,  lowerCAmelCase_)]  ,  dim=1)
  
  																A    =      []
  																# If the number of encoder and decoder layers are present in the model configuration, both are considered
  																A    ,					A    =      self.num_layers
  																A    =      min(lowerCAmelCase_  ,  lowerCAmelCase_)
  																A    =      max(lowerCAmelCase_  ,  lowerCAmelCase_) - min_num_layers
  																A    =      "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.
  																A    =      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       SCREAMING_SNAKE_CASE__     (self				:	Union[str, Any]  ,  __SCREAMING_SNAKE_CASE				:	PreTrainedTokenizer  ,  __SCREAMING_SNAKE_CASE				:	int = -1  ,  __SCREAMING_SNAKE_CASE				:	int = -1  ,  __SCREAMING_SNAKE_CASE				:	bool = False  ,  __SCREAMING_SNAKE_CASE				:	Optional[TensorType] = None  ,  ):
  											A    =      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
  																A    ,					A    =      common_inputs["input_ids"].shape
  																# Not using the same length for past_key_values
  																A    =      seqlen + 2
  																A    ,					A    =      self.num_layers
  																A    ,					A    =      self.num_attention_heads
  																A    =      (
  																    batch,
  																    num_encoder_attention_heads,
  																    past_key_values_length,
  																    self._config.hidden_size // num_encoder_attention_heads,
  																)
  
  																A    =      common_inputs["attention_mask"].dtype
  																A    =      torch.cat(
  																    [common_inputs["attention_mask"], torch.ones(lowerCAmelCase_  ,  lowerCAmelCase_  ,  dtype=lowerCAmelCase_)]  ,  dim=1)
  																A    =      [
  																    (torch.zeros(lowerCAmelCase_), torch.zeros(lowerCAmelCase_)) for _ in range(lowerCAmelCase_)
  																]
  											return common_inputs
  
  
  						def       SCREAMING_SNAKE_CASE__     (self				:	Dict  ,  __SCREAMING_SNAKE_CASE				:	PreTrainedTokenizer  ,  __SCREAMING_SNAKE_CASE				:	int = -1  ,  __SCREAMING_SNAKE_CASE				:	int = -1  ,  __SCREAMING_SNAKE_CASE				:	bool = False  ,  __SCREAMING_SNAKE_CASE				:	Optional[TensorType] = None  ,  ):
  											A    =      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
  											A    =      tokenizer.num_special_tokens_to_add(lowerCAmelCase_)
  											A    =      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
  											A    =      [" ".join([tokenizer.unk_token]) * seq_length] * batch_size
  											A    =      dict(tokenizer(lowerCAmelCase_  ,  return_tensors=lowerCAmelCase_))
  											return common_inputs
  
  
  						def       SCREAMING_SNAKE_CASE__     (self				:	List[str]  ,  __SCREAMING_SNAKE_CASE				:	PreTrainedTokenizer  ,  __SCREAMING_SNAKE_CASE				:	int = -1  ,  __SCREAMING_SNAKE_CASE				:	int = -1  ,  __SCREAMING_SNAKE_CASE				:	bool = False  ,  __SCREAMING_SNAKE_CASE				:	Optional[TensorType] = None  ,  ):
  
  
  
  
  
  
  											if self.task in ["default", "seq2seq-lm"]:
  																A    =      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":
  																A    =      self._generate_dummy_inputs_for_causal_lm(
  																    lowerCAmelCase_  ,  batch_size=lowerCAmelCase_  ,  seq_length=lowerCAmelCase_  ,  is_pair=lowerCAmelCase_  ,  framework=lowerCAmelCase_)
  											else:
  																A    =      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       SCREAMING_SNAKE_CASE__     (self				:	Optional[Any]  ,  __SCREAMING_SNAKE_CASE				:	Dict  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]  ,  __SCREAMING_SNAKE_CASE				:	str  ,  __SCREAMING_SNAKE_CASE				:	List[Any]):
  
  
  
  
  
  
  											if self.task in ["default", "seq2seq-lm"]:
  																A    =      super()._flatten_past_key_values_(lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_)
  											else:
  																A    =      super(lowerCAmelCase_  ,  self)._flatten_past_key_values_(
  																    lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_  ,  lowerCAmelCase_)
  
  
  
  
  
  
style_context: 
  
  """simple docstring"""
  
  
  
  
  def      __SCREAMING_SNAKE_CASE		(		lowercase__    ,							lowercase__   ):
  					"""simple docstring"""
  					A    =      1
  					while b > 0:
  										if b & 1:
  															res *= a
  
  										a *= a
  										b >>= 1
  
  					return res
  def      __SCREAMING_SNAKE_CASE		(		lowercase__    ,							lowercase__    ,							lowercase__   ):
  					"""simple docstring"""
  					A    =      1
  					while b > 0:
  										if b & 1:
  															A    =      ((res % c) * (a % c)) % c
  
  										a *= a
  										b >>= 1
  
  					return res
  
  
  
  
  
  