

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

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


__A			:					List[str]						=			logging.get_logger(__name__)

__A			:					List[str]						=			{
    'facebook/blenderbot_small-90M': 'https://huggingface.co/facebook/blenderbot_small-90M/resolve/main/config.json',
    # See all BlenderbotSmall models at https://huggingface.co/models?filter=blenderbot_small
}





class 			_SCREAMING_SNAKE_CASE (   __snake_case		):







   '''simple docstring'''




   lowerCamelCase__				=      "blenderbot-small"
   lowerCamelCase__				=      ["past_key_values"]
   lowerCamelCase__				=      {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}





   def __init__(       self					:			List[Any]     , __lowerCamelCase					:			List[str]=50265     , __lowerCamelCase					:			List[Any]=512     , __lowerCamelCase					:			Optional[Any]=8     , __lowerCamelCase					:			str=2048     , __lowerCamelCase					:			str=16     , __lowerCamelCase					:			Optional[int]=8     , __lowerCamelCase					:			Optional[int]=2048     , __lowerCamelCase					:			str=16     , __lowerCamelCase					:			int=0.0     , __lowerCamelCase					:			Any=0.0     , __lowerCamelCase					:			Tuple=True     , __lowerCamelCase					:			Optional[int]=True     , __lowerCamelCase					:			int="gelu"     , __lowerCamelCase					:			str=512     , __lowerCamelCase					:			List[Any]=0.1     , __lowerCamelCase					:			List[str]=0.0     , __lowerCamelCase					:			Optional[Any]=0.0     , __lowerCamelCase					:			Union[str, Any]=0.02     , __lowerCamelCase					:			Union[str, Any]=1     , __lowerCamelCase					:			List[Any]=False     , __lowerCamelCase					:			int=0     , __lowerCamelCase					:			Optional[Any]=1     , __lowerCamelCase					:			List[str]=2     , __lowerCamelCase					:			Optional[Any]=2     , **__lowerCamelCase					:			Optional[int]     , ):
       SCREAMING_SNAKE_CASE										=   vocab_size
       SCREAMING_SNAKE_CASE										=   max_position_embeddings
       SCREAMING_SNAKE_CASE										=   d_model
       SCREAMING_SNAKE_CASE										=   encoder_ffn_dim
       SCREAMING_SNAKE_CASE										=   encoder_layers
       SCREAMING_SNAKE_CASE										=   encoder_attention_heads
       SCREAMING_SNAKE_CASE										=   decoder_ffn_dim
       SCREAMING_SNAKE_CASE										=   decoder_layers
       SCREAMING_SNAKE_CASE										=   decoder_attention_heads
       SCREAMING_SNAKE_CASE										=   dropout
       SCREAMING_SNAKE_CASE										=   attention_dropout
       SCREAMING_SNAKE_CASE										=   activation_dropout
       SCREAMING_SNAKE_CASE										=   activation_function
       SCREAMING_SNAKE_CASE										=   init_std
       SCREAMING_SNAKE_CASE										=   encoder_layerdrop
       SCREAMING_SNAKE_CASE										=   decoder_layerdrop
       SCREAMING_SNAKE_CASE										=   use_cache
       SCREAMING_SNAKE_CASE										=   encoder_layers
       SCREAMING_SNAKE_CASE										=   scale_embedding  # scale factor will be sqrt(d_model) if True

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





class 			_SCREAMING_SNAKE_CASE (   __snake_case		):







   '''simple docstring'''




   @property
   def      _snake_case		(       self					:			Any			):
       if self.task in ["default", "seq2seq-lm"]:
           SCREAMING_SNAKE_CASE										=   OrderedDict(
               [
                   ("input_ids", {0: "batch", 1: "encoder_sequence"}),
                   ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
               ]			)

           if self.use_past:
               SCREAMING_SNAKE_CASE										=   {0: "batch"}
               SCREAMING_SNAKE_CASE										=   {0: "batch", 1: "past_decoder_sequence + sequence"}
           else:
               SCREAMING_SNAKE_CASE										=   {0: "batch", 1: "decoder_sequence"}
               SCREAMING_SNAKE_CASE										=   {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.
           SCREAMING_SNAKE_CASE										=   OrderedDict(
               [
                   ("input_ids", {0: "batch", 1: "encoder_sequence"}),
                   ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
               ]			)
           if self.use_past:
               SCREAMING_SNAKE_CASE							,	SCREAMING_SNAKE_CASE										=   self.num_layers
               for i in range(__lowerCamelCase			):
                   SCREAMING_SNAKE_CASE										=   {0: "batch", 2: "past_sequence + sequence"}
                   SCREAMING_SNAKE_CASE										=   {0: "batch", 2: "past_sequence + sequence"}
       else:
           SCREAMING_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      _snake_case		(       self					:			Optional[int]			):
       if self.task in ["default", "seq2seq-lm"]:
           SCREAMING_SNAKE_CASE										=   super().outputs
       else:
           SCREAMING_SNAKE_CASE										=   super(__lowerCamelCase     , self			).outputs
           if self.use_past:
               SCREAMING_SNAKE_CASE							,	SCREAMING_SNAKE_CASE										=   self.num_layers
               for i in range(__lowerCamelCase			):
                   SCREAMING_SNAKE_CASE										=   {0: "batch", 2: "past_sequence + sequence"}
                   SCREAMING_SNAKE_CASE										=   {0: "batch", 2: "past_sequence + sequence"}
       return common_outputs





   def      _snake_case		(       self					:			Any     , __lowerCamelCase					:			PreTrainedTokenizer     , __lowerCamelCase					:			int = -1     , __lowerCamelCase					:			int = -1     , __lowerCamelCase					:			bool = False     , __lowerCamelCase					:			Optional[TensorType] = None     , ):
       SCREAMING_SNAKE_CASE										=   self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
           __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase			)

       # Generate decoder inputs
       SCREAMING_SNAKE_CASE										=   seq_length if not self.use_past else 1
       SCREAMING_SNAKE_CASE										=   self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
           __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase			)
       SCREAMING_SNAKE_CASE										=   {f"decoder_{name}": tensor for name, tensor in decoder_inputs.items()}
       SCREAMING_SNAKE_CASE										=   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
           SCREAMING_SNAKE_CASE							,	SCREAMING_SNAKE_CASE										=   common_inputs["input_ids"].shape
           SCREAMING_SNAKE_CASE										=   common_inputs["decoder_input_ids"].shape[1]
           SCREAMING_SNAKE_CASE							,	SCREAMING_SNAKE_CASE										=   self.num_attention_heads
           SCREAMING_SNAKE_CASE										=   (
               batch,
               num_encoder_attention_heads,
               encoder_seq_length,
               self._config.hidden_size // num_encoder_attention_heads,
           )
           SCREAMING_SNAKE_CASE										=   decoder_seq_length + 3
           SCREAMING_SNAKE_CASE										=   (
               batch,
               num_decoder_attention_heads,
               decoder_past_length,
               self._config.hidden_size // num_decoder_attention_heads,
           )

           SCREAMING_SNAKE_CASE										=   torch.cat(
               [common_inputs["decoder_attention_mask"], torch.ones(__lowerCamelCase     , __lowerCamelCase			)]     , dim=1			)

           SCREAMING_SNAKE_CASE										=   []
           # If the number of encoder and decoder layers are present in the model configuration, both are considered
           SCREAMING_SNAKE_CASE							,	SCREAMING_SNAKE_CASE										=   self.num_layers
           SCREAMING_SNAKE_CASE										=   min(__lowerCamelCase     , __lowerCamelCase			)
           SCREAMING_SNAKE_CASE										=   max(__lowerCamelCase     , __lowerCamelCase			) - min_num_layers
           SCREAMING_SNAKE_CASE										=   "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.
           SCREAMING_SNAKE_CASE										=   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      _snake_case		(       self					:			Optional[Any]     , __lowerCamelCase					:			PreTrainedTokenizer     , __lowerCamelCase					:			int = -1     , __lowerCamelCase					:			int = -1     , __lowerCamelCase					:			bool = False     , __lowerCamelCase					:			Optional[TensorType] = None     , ):
       SCREAMING_SNAKE_CASE										=   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
           SCREAMING_SNAKE_CASE							,	SCREAMING_SNAKE_CASE										=   common_inputs["input_ids"].shape
           # Not using the same length for past_key_values
           SCREAMING_SNAKE_CASE										=   seqlen + 2
           SCREAMING_SNAKE_CASE							,	SCREAMING_SNAKE_CASE										=   self.num_layers
           SCREAMING_SNAKE_CASE							,	SCREAMING_SNAKE_CASE										=   self.num_attention_heads
           SCREAMING_SNAKE_CASE										=   (
               batch,
               num_encoder_attention_heads,
               past_key_values_length,
               self._config.hidden_size // num_encoder_attention_heads,
           )

           SCREAMING_SNAKE_CASE										=   common_inputs["attention_mask"].dtype
           SCREAMING_SNAKE_CASE										=   torch.cat(
               [common_inputs["attention_mask"], torch.ones(__lowerCamelCase     , __lowerCamelCase     , dtype=__lowerCamelCase			)]     , dim=1			)
           SCREAMING_SNAKE_CASE										=   [
               (torch.zeros(__lowerCamelCase			), torch.zeros(__lowerCamelCase			)) for _ in range(__lowerCamelCase			)
           ]
       return common_inputs





   def      _snake_case		(       self					:			Tuple     , __lowerCamelCase					:			PreTrainedTokenizer     , __lowerCamelCase					:			int = -1     , __lowerCamelCase					:			int = -1     , __lowerCamelCase					:			bool = False     , __lowerCamelCase					:			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
       SCREAMING_SNAKE_CASE										=   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
       SCREAMING_SNAKE_CASE										=   tokenizer.num_special_tokens_to_add(__lowerCamelCase			)
       SCREAMING_SNAKE_CASE										=   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
       SCREAMING_SNAKE_CASE										=   [" ".join([tokenizer.unk_token]			) * seq_length] * batch_size
       SCREAMING_SNAKE_CASE										=   dict(tokenizer(__lowerCamelCase     , return_tensors=__lowerCamelCase			)			)
       return common_inputs





   def      _snake_case		(       self					:			Optional[Any]     , __lowerCamelCase					:			PreTrainedTokenizer     , __lowerCamelCase					:			int = -1     , __lowerCamelCase					:			int = -1     , __lowerCamelCase					:			bool = False     , __lowerCamelCase					:			Optional[TensorType] = None     , ):
       if self.task in ["default", "seq2seq-lm"]:
           SCREAMING_SNAKE_CASE										=   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":
           SCREAMING_SNAKE_CASE										=   self._generate_dummy_inputs_for_causal_lm(
               __lowerCamelCase     , batch_size=__lowerCamelCase     , seq_length=__lowerCamelCase     , is_pair=__lowerCamelCase     , framework=__lowerCamelCase			)
       else:
           SCREAMING_SNAKE_CASE										=   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      _snake_case		(       self					:			Optional[int]     , __lowerCamelCase					:			Union[str, Any]     , __lowerCamelCase					:			Union[str, Any]     , __lowerCamelCase					:			Dict     , __lowerCamelCase					:			int			):
       if self.task in ["default", "seq2seq-lm"]:
           SCREAMING_SNAKE_CASE										=   super()._flatten_past_key_values_(__lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase			)
       else:
           SCREAMING_SNAKE_CASE										=   super(__lowerCamelCase     , self			)._flatten_past_key_values_(
               __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase     , __lowerCamelCase			)


import os





def 	__a     (      ):
    SCREAMING_SNAKE_CASE										=   os.path.join(os.path.dirname(A__       )			,  "num.txt"       )
    with open(A__       ) as file_hand:
        return str(sum(int(A__       ) for line in file_hand       )       )[:10]


if __name__ == "__main__":
    print(solution())