code: 
  
  
  
  
  
  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
  
  
  lowerCAmelCase_   =   logging.get_logger(__name__)
  
  lowerCAmelCase_   =   {
      "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 				A    (__UpperCAmelCase				):
        _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     ,  lowercase_=9_6103     ,  lowercase_=4096     ,  lowercase_=16     ,  lowercase_=4096     ,  lowercase_=16     ,  lowercase_=16     ,  lowercase_=4096     ,  lowercase_=16     ,  lowercase_=0.0     ,  lowercase_=0.0     ,  lowercase_=True     ,  lowercase_=True     ,  lowercase_="gelu_new"     ,  lowercase_=1024     ,  lowercase_=0.1     ,  lowercase_=0.0     ,  lowercase_=0.0     ,  lowercase_=0.02     ,  lowercase_=2     ,  lowercase_=0.0     ,  lowercase_=True     ,  lowercase_=0     ,  lowercase_=2     ,  lowercase_=1     ,  lowercase_="block_sparse"     ,  lowercase_=64     ,  lowercase_=3     ,  lowercase_=False     ,  **lowercase_     ,  )      ->   Tuple:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							List[str]     				=						vocab_size
               _snake_case      :							Optional[Any]     				=						max_position_embeddings
               _snake_case      :							Any     				=						d_model
               _snake_case      :							Dict     				=						encoder_ffn_dim
               _snake_case      :							Tuple     				=						encoder_layers
               _snake_case      :							Dict     				=						encoder_attention_heads
               _snake_case      :							str     				=						decoder_ffn_dim
               _snake_case      :							str     				=						decoder_layers
               _snake_case      :							Tuple     				=						decoder_attention_heads
               _snake_case      :							str     				=						dropout
               _snake_case      :							List[str]     				=						attention_dropout
               _snake_case      :							Dict     				=						activation_dropout
               _snake_case      :							str     				=						activation_function
               _snake_case      :							Union[str, Any]     				=						init_std
               _snake_case      :							Optional[int]     				=						encoder_layerdrop
               _snake_case      :							Tuple     				=						decoder_layerdrop
               _snake_case      :							Optional[int]     				=						classifier_dropout
               _snake_case      :							str     				=						use_cache
               _snake_case      :							List[Any]     				=						encoder_layers
               _snake_case      :							List[str]     				=						scale_embedding  # scale factor will be sqrt(d_model) if True
  
               # extra config
               _snake_case      :							Optional[Any]     				=						attention_type
               _snake_case      :							Any     				=						block_size
               _snake_case      :							Any     				=						num_random_blocks
               _snake_case      :							Optional[int]     				=						use_bias
  
               super().__init__(
                   pad_token_id=lowercase_     ,  bos_token_id=lowercase_     ,  eos_token_id=lowercase_     ,  is_encoder_decoder=lowercase_     ,  decoder_start_token_id=lowercase_     ,  **lowercase_     ,  )
  
  
  class 				A    (__UpperCAmelCase				):
  
  
  
        @property
        def    __a (					self					)      ->   Mapping[str, Mapping[int, str]]:
  
  
  
               '''simple docstring'''
  
               if self.task in ["default", "seq2seq-lm"]:
                      _snake_case      :							Dict     				=						OrderedDict(
                          [
                              ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
                              ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
                          ]					)
  
                      if self.use_past:
                             _snake_case      :							Any     				=						{0: '''batch'''}
                             _snake_case      :							Optional[int]     				=						{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
                      else:
                             _snake_case      :							Union[str, Any]     				=						{0: '''batch''', 1: '''decoder_sequence'''}
                             _snake_case      :							Any     				=						{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      :							Union[str, Any]     				=						OrderedDict(
                          [
                              ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
                              ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
                          ]					)
                      if self.use_past:
                             _snake_case				,    _snake_case      :							List[str]     				=						self.num_layers
                             for i in range(lowercase_					):
                                    _snake_case      :							Dict     				=						{0: '''batch''', 2: '''past_sequence + sequence'''}
                                    _snake_case      :							int     				=						{0: '''batch''', 2: '''past_sequence + sequence'''}
               else:
                      _snake_case      :							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    __a (					self					)      ->   Mapping[str, Mapping[int, str]]:
  
  
  
               '''simple docstring'''
  
               if self.task in ["default", "seq2seq-lm"]:
                      _snake_case      :							str     				=						super().outputs
               else:
                      _snake_case      :							Optional[Any]     				=						super(lowercase_     ,  self					).outputs
                      if self.use_past:
                             _snake_case				,    _snake_case      :							Union[str, Any]     				=						self.num_layers
                             for i in range(lowercase_					):
                                    _snake_case      :							int     				=						{0: '''batch''', 2: '''past_sequence + sequence'''}
                                    _snake_case      :							List[Any]     				=						{0: '''batch''', 2: '''past_sequence + sequence'''}
               return common_outputs
  
  
  
        def    __a (					self     ,  lowercase_     ,  lowercase_ = -1     ,  lowercase_ = -1     ,  lowercase_ = False     ,  lowercase_ = None     ,  )      ->   Mapping[str, Any]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Union[str, Any]     				=						self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                   lowercase_     ,  lowercase_     ,  lowercase_     ,  lowercase_     ,  lowercase_					)
  
               # Generate decoder inputs
               _snake_case      :							int     				=						seq_length if not self.use_past else 1
               _snake_case      :							Union[str, Any]     				=						self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                   lowercase_     ,  lowercase_     ,  lowercase_     ,  lowercase_     ,  lowercase_					)
               _snake_case      :							int     				=						{F'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
               _snake_case      :							int     				=						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      :							int     				=						common_inputs['''input_ids'''].shape
                      _snake_case      :							Optional[Any]     				=						common_inputs['''decoder_input_ids'''].shape[1]
                      _snake_case				,    _snake_case      :							Optional[Any]     				=						self.num_attention_heads
                      _snake_case      :							Optional[Any]     				=						(
                          batch,
                          num_encoder_attention_heads,
                          encoder_seq_length,
                          self._config.hidden_size // num_encoder_attention_heads,
                      )
                      _snake_case      :							int     				=						decoder_seq_length + 3
                      _snake_case      :							str     				=						(
                          batch,
                          num_decoder_attention_heads,
                          decoder_past_length,
                          self._config.hidden_size // num_decoder_attention_heads,
                      )
  
                      _snake_case      :							List[str]     				=						torch.cat(
                          [common_inputs['''decoder_attention_mask'''], torch.ones(lowercase_     ,  lowercase_					)]     ,  dim=1					)
  
                      _snake_case      :							Optional[int]     				=						[]
                      # If the number of encoder and decoder layers are present in the model configuration, both are considered
                      _snake_case				,    _snake_case      :							int     				=						self.num_layers
                      _snake_case      :							Tuple     				=						min(lowercase_     ,  lowercase_					)
                      _snake_case      :							Union[str, Any]     				=						max(lowercase_     ,  lowercase_					) - min_num_layers
                      _snake_case      :							Dict     				=						'''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      :							Optional[int]     				=						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     ,  lowercase_     ,  lowercase_ = -1     ,  lowercase_ = -1     ,  lowercase_ = False     ,  lowercase_ = None     ,  )      ->   Mapping[str, Any]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							str     				=						self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                   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      :							int     				=						common_inputs['''input_ids'''].shape
                      # Not using the same length for past_key_values
                      _snake_case      :							str     				=						seqlen + 2
                      _snake_case				,    _snake_case      :							Dict     				=						self.num_layers
                      _snake_case				,    _snake_case      :							str     				=						self.num_attention_heads
                      _snake_case      :							Optional[int]     				=						(
                          batch,
                          num_encoder_attention_heads,
                          past_key_values_length,
                          self._config.hidden_size // num_encoder_attention_heads,
                      )
  
                      _snake_case      :							List[str]     				=						common_inputs['''attention_mask'''].dtype
                      _snake_case      :							Tuple     				=						torch.cat(
                          [common_inputs['''attention_mask'''], torch.ones(lowercase_     ,  lowercase_     ,  dtype=lowercase_					)]     ,  dim=1					)
                      _snake_case      :							Dict     				=						[
                          (torch.zeros(lowercase_					), torch.zeros(lowercase_					)) for _ in range(lowercase_					)
                      ]
               return common_inputs
  
  
  
        def    __a (					self     ,  lowercase_     ,  lowercase_ = -1     ,  lowercase_ = -1     ,  lowercase_ = False     ,  lowercase_ = None     ,  )      ->   Mapping[str, Any]:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Optional[Any]     				=						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      :							str     				=						tokenizer.num_special_tokens_to_add(lowercase_					)
               _snake_case      :							Any     				=						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      :							int     				=						[''' '''.join([tokenizer.unk_token]					) * seq_length] * batch_size
               _snake_case      :							List[Any]     				=						dict(tokenizer(lowercase_     ,  return_tensors=lowercase_					)					)
               return common_inputs
  
  
  
        def    __a (					self     ,  lowercase_     ,  lowercase_ = -1     ,  lowercase_ = -1     ,  lowercase_ = False     ,  lowercase_ = None     ,  )      ->   Mapping[str, Any]:
  
  
  
               '''simple docstring'''
  
               if self.task in ["default", "seq2seq-lm"]:
                      _snake_case      :							Tuple     				=						self._generate_dummy_inputs_for_default_and_seqaseq_lm(
                          lowercase_     ,  batch_size=lowercase_     ,  seq_length=lowercase_     ,  is_pair=lowercase_     ,  framework=lowercase_					)
  
               elif self.task == "causal-lm":
                      _snake_case      :							int     				=						self._generate_dummy_inputs_for_causal_lm(
                          lowercase_     ,  batch_size=lowercase_     ,  seq_length=lowercase_     ,  is_pair=lowercase_     ,  framework=lowercase_					)
               else:
                      _snake_case      :							Dict     				=						self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                          lowercase_     ,  batch_size=lowercase_     ,  seq_length=lowercase_     ,  is_pair=lowercase_     ,  framework=lowercase_					)
  
               return common_inputs
  
  
  
        def    __a (					self     ,  lowercase_     ,  lowercase_     ,  lowercase_     ,  lowercase_					)      ->   Union[str, Any]:
  
  
  
               '''simple docstring'''
  
               if self.task in ["default", "seq2seq-lm"]:
                      _snake_case      :							int     				=						super()._flatten_past_key_values_(lowercase_     ,  lowercase_     ,  lowercase_     ,  lowercase_					)
               else:
                      _snake_case      :							Optional[int]     				=						super(lowercase_     ,  self					)._flatten_past_key_values_(
                          lowercase_     ,  lowercase_     ,  lowercase_     ,  lowercase_					)
  
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  from __future__ import annotations
  
  class 				A    :
  
  
  
        def __init__(					self     ,  lowercase_					)      ->   None:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							Optional[Any]     				=						vertices
               _snake_case      :							int     				=						[[0] * vertices for _ in range(lowercase_					)]
  
  
  
        def    __a (					self     ,  lowercase_					)      ->   None:
  
  
  
               '''simple docstring'''
  
               print('''Vertex \t Distance from Source'''					)
               for vertex in range(self.vertices					):
                      print(lowercase_     ,  '''\t\t'''     ,  distances_from_source[vertex]					)
  
  
  
        def    __a (					self     ,  lowercase_     ,  lowercase_					)      ->   int:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							List[Any]     				=						1E7
               _snake_case      :							Tuple     				=						0
  
               # Search not nearest vertex not in the shortest path tree
               for vertex in range(self.vertices					):
                      if distances_from_source[vertex] < minimum and visited[vertex] is False:
                             _snake_case      :							Dict     				=						distances_from_source[vertex]
                             _snake_case      :							int     				=						vertex
               return min_index
  
  
  
        def    __a (					self     ,  lowercase_					)      ->   None:
  
  
  
               '''simple docstring'''
  
               _snake_case      :							List[Any]     				=						[int(1E7					)] * self.vertices  # distances from the source
               _snake_case      :							List[Any]     				=						0
               _snake_case      :							List[str]     				=						[False] * self.vertices
  
               for _ in range(self.vertices					):
                      _snake_case      :							List[Any]     				=						self.minimum_distance(lowercase_     ,  lowercase_					)
                      _snake_case      :							List[str]     				=						True
  
                      # Update dist value of the adjacent vertices
                      # of the picked vertex only if the current
                      # distance is greater than new distance and
                      # the vertex in not in the shortest path tree
                      for v in range(self.vertices					):
                             if (
                                 self.graph[u][v] > 0
                                 and visited[v] is False
                                 and distances[v] > distances[u] + self.graph[u][v]
                             ):
                                    _snake_case      :							Any     				=						distances[u] + self.graph[u][v]
  
               self.print_solution(lowercase_					)
  
  
  if __name__ == "__main__":
     lowerCAmelCase_   =   Graph(9)
     lowerCAmelCase_   =   [
         [0, 4, 0, 0, 0, 0, 0, 8, 0],
         [4, 0, 8, 0, 0, 0, 0, 1_1, 0],
         [0, 8, 0, 7, 0, 4, 0, 0, 2],
         [0, 0, 7, 0, 9, 1_4, 0, 0, 0],
         [0, 0, 0, 9, 0, 1_0, 0, 0, 0],
         [0, 0, 4, 1_4, 1_0, 0, 2, 0, 0],
         [0, 0, 0, 0, 0, 2, 0, 1, 6],
         [8, 1_1, 0, 0, 0, 0, 1, 0, 7],
         [0, 0, 2, 0, 0, 0, 6, 7, 0],
     ]
     graph.dijkstra(0)
  
  
  
  
  
  
  