





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

__A									=				{
    "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						(	UpperCAmelCase__    ):







 '''simple docstring'''
 lowercase_		=			'blenderbot-small'
 lowercase_		=			['past_key_values']
 lowercase_		=			{'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}

 def __init__(self				:   str       , UpperCAmelCase_				:   List[Any]=50_265       , UpperCAmelCase_				:   Tuple=512       , UpperCAmelCase_				:   List[Any]=8       , UpperCAmelCase_				:   Dict=2_048       , UpperCAmelCase_				:   Union[str, Any]=16       , UpperCAmelCase_				:   Any=8       , UpperCAmelCase_				:   str=2_048       , UpperCAmelCase_				:   Optional[int]=16       , UpperCAmelCase_				:   str=0.0       , UpperCAmelCase_				:   Tuple=0.0       , UpperCAmelCase_				:   Optional[Any]=True       , UpperCAmelCase_				:   List[Any]=True       , UpperCAmelCase_				:   int="gelu"       , UpperCAmelCase_				:   List[str]=512       , UpperCAmelCase_				:   Any=0.1       , UpperCAmelCase_				:   List[Any]=0.0       , UpperCAmelCase_				:   Dict=0.0       , UpperCAmelCase_				:   Union[str, Any]=0.02       , UpperCAmelCase_				:   List[Any]=1       , UpperCAmelCase_				:   List[Any]=False       , UpperCAmelCase_				:   Union[str, Any]=0       , UpperCAmelCase_				:   List[str]=1       , UpperCAmelCase_				:   Optional[int]=2       , UpperCAmelCase_				:   Any=2       , **UpperCAmelCase_				:   Tuple       , )       ->str:



   '''simple docstring'''



   lowerCamelCase__:      Any			  =vocab_size
   lowerCamelCase__:      Any			  =max_position_embeddings
   lowerCamelCase__:      str			  =d_model
   lowerCamelCase__:      List[Any]			  =encoder_ffn_dim
   lowerCamelCase__:      Union[str, Any]			  =encoder_layers
   lowerCamelCase__:      List[str]			  =encoder_attention_heads
   lowerCamelCase__:      Optional[Any]			  =decoder_ffn_dim
   lowerCamelCase__:      List[Any]			  =decoder_layers
   lowerCamelCase__:      Any			  =decoder_attention_heads
   lowerCamelCase__:      Union[str, Any]			  =dropout
   lowerCamelCase__:      Union[str, Any]			  =attention_dropout
   lowerCamelCase__:      int			  =activation_dropout
   lowerCamelCase__:      int			  =activation_function
   lowerCamelCase__:      Optional[Any]			  =init_std
   lowerCamelCase__:      List[str]			  =encoder_layerdrop
   lowerCamelCase__:      List[str]			  =decoder_layerdrop
   lowerCamelCase__:      List[str]			  =use_cache
   lowerCamelCase__:      Union[str, Any]			  =encoder_layers
   lowerCamelCase__:      Any			  =scale_embedding  # scale factor will be sqrt(d_model) if True

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



class    _SCREAMING_SNAKE_CASE						(	UpperCAmelCase__    ):







 '''simple docstring'''

 @property
 def 							SCREAMING_SNAKE_CASE_					(self				:   Optional[int])       ->Mapping[str, Mapping[int, str]]:



   '''simple docstring'''



   if self.task in ["default", "seq2seq-lm"]:
     lowerCamelCase__:      Dict			  =OrderedDict(
         [
             ("input_ids", {0: "batch", 1: "encoder_sequence"}),
             ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
         ])

     if self.use_past:
       lowerCamelCase__:      int			  ={0: """batch"""}
       lowerCamelCase__:      List[Any]			  ={0: """batch""", 1: """past_decoder_sequence + sequence"""}
     else:
       lowerCamelCase__:      Optional[Any]			  ={0: """batch""", 1: """decoder_sequence"""}
       lowerCamelCase__:      Any			  ={0: """batch""", 1: """decoder_sequence"""}

     if self.use_past:
       self.fill_with_past_key_values_(_SCREAMING_SNAKE_CASE       , direction="inputs")
   elif self.task == "causal-lm":
     # TODO: figure this case out.
     lowerCamelCase__:      int			  =OrderedDict(
         [
             ("input_ids", {0: "batch", 1: "encoder_sequence"}),
             ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
         ])
     if self.use_past:
       lowerCamelCase__:      Tuple			  =self.num_layers
       for i in range(_SCREAMING_SNAKE_CASE):
         lowerCamelCase__:      Optional[Any]			  ={0: """batch""", 2: """past_sequence + sequence"""}
         lowerCamelCase__:      List[Any]			  ={0: """batch""", 2: """past_sequence + sequence"""}
   else:
     lowerCamelCase__:      Dict			  =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				:   Union[str, Any])       ->Mapping[str, Mapping[int, str]]:



   '''simple docstring'''



   if self.task in ["default", "seq2seq-lm"]:
     lowerCamelCase__:      Union[str, Any]			  =super().outputs
   else:
     lowerCamelCase__:      int			  =super(_SCREAMING_SNAKE_CASE       , self).outputs
     if self.use_past:
       lowerCamelCase__:      Any			  =self.num_layers
       for i in range(_SCREAMING_SNAKE_CASE):
         lowerCamelCase__:      List[str]			  ={0: """batch""", 2: """past_sequence + sequence"""}
         lowerCamelCase__:      List[str]			  ={0: """batch""", 2: """past_sequence + sequence"""}
   return common_outputs

 def 							SCREAMING_SNAKE_CASE_					(self				:   Union[str, Any]       , UpperCAmelCase_				:   Optional[int]       , UpperCAmelCase_				:   str = -1       , UpperCAmelCase_				:   int = -1       , UpperCAmelCase_				:   Any = False       , UpperCAmelCase_				:   Optional[int] = None       , )       ->Mapping[str, Any]:



   '''simple docstring'''



   lowerCamelCase__:      Dict			  =self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
       _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE)

   # Generate decoder inputs
   lowerCamelCase__:      Optional[Any]			  =seq_length if not self.use_past else 1
   lowerCamelCase__:      Dict			  =self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
       _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE)
   lowerCamelCase__:      Any			  ={F"""decoder_{name}""": tensor for name, tensor in decoder_inputs.items()}
   lowerCamelCase__:      Union[str, Any]			  =dict(**_SCREAMING_SNAKE_CASE       , **_SCREAMING_SNAKE_CASE)

   if self.use_past:
     if not is_torch_available():
       raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed.")
     else:
       import torch
     lowerCamelCase__:      int			  =common_inputs["""input_ids"""].shape
     lowerCamelCase__:      Any			  =common_inputs["""decoder_input_ids"""].shape[1]
     lowerCamelCase__:      str			  =self.num_attention_heads
     lowerCamelCase__:      Union[str, Any]			  =(
         batch,
         num_encoder_attention_heads,
         encoder_seq_length,
         self._config.hidden_size // num_encoder_attention_heads,
     )
     lowerCamelCase__:      Union[str, Any]			  =decoder_seq_length + 3
     lowerCamelCase__:      Union[str, Any]			  =(
         batch,
         num_decoder_attention_heads,
         decoder_past_length,
         self._config.hidden_size // num_decoder_attention_heads,
     )

     lowerCamelCase__:      Optional[Any]			  =torch.cat(
         [common_inputs["decoder_attention_mask"], torch.ones(_SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE)]       , dim=1)

     lowerCamelCase__:      List[str]			  =[]
     # If the number of encoder and decoder layers are present in the model configuration, both are considered
     lowerCamelCase__:      List[Any]			  =self.num_layers
     lowerCamelCase__:      Optional[Any]			  =min(_SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE)
     lowerCamelCase__:      Optional[Any]			  =max(_SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE) - min_num_layers
     lowerCamelCase__:      Optional[int]			  ="""encoder""" if num_encoder_layers > num_decoder_layers else """decoder"""

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

 def 							SCREAMING_SNAKE_CASE_					(self				:   str       , UpperCAmelCase_				:   Optional[int]       , UpperCAmelCase_				:   Optional[Any] = -1       , UpperCAmelCase_				:   str = -1       , UpperCAmelCase_				:   int = False       , UpperCAmelCase_				:   Dict = None       , )       ->Mapping[str, Any]:



   '''simple docstring'''



   lowerCamelCase__:      Tuple			  =self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
       _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE)

   if self.use_past:
     if not is_torch_available():
       raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed.")
     else:
       import torch
     lowerCamelCase__:      Optional[Any]			  =common_inputs["""input_ids"""].shape
     # Not using the same length for past_key_values
     lowerCamelCase__:      Union[str, Any]			  =seqlen + 2
     lowerCamelCase__:      Optional[int]			  =self.num_layers
     lowerCamelCase__:      Dict			  =self.num_attention_heads
     lowerCamelCase__:      Any			  =(
         batch,
         num_encoder_attention_heads,
         past_key_values_length,
         self._config.hidden_size // num_encoder_attention_heads,
     )

     lowerCamelCase__:      List[Any]			  =common_inputs["""attention_mask"""].dtype
     lowerCamelCase__:      Any			  =torch.cat(
         [common_inputs["attention_mask"], torch.ones(_SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , dtype=_SCREAMING_SNAKE_CASE)]       , dim=1)
     lowerCamelCase__:      List[str]			  =[
         (torch.zeros(_SCREAMING_SNAKE_CASE), torch.zeros(_SCREAMING_SNAKE_CASE)) for _ in range(_SCREAMING_SNAKE_CASE)
     ]
   return common_inputs

 def 							SCREAMING_SNAKE_CASE_					(self				:   List[str]       , UpperCAmelCase_				:   Tuple       , UpperCAmelCase_				:   Any = -1       , UpperCAmelCase_				:   Optional[Any] = -1       , UpperCAmelCase_				:   Optional[int] = False       , UpperCAmelCase_				:   Any = None       , )       ->Mapping[str, Any]:



   '''simple docstring'''



   lowerCamelCase__:      str			  =compute_effective_axis_dimension(
       _SCREAMING_SNAKE_CASE       , 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
   lowerCamelCase__:      List[str]			  =tokenizer.num_special_tokens_to_add(_SCREAMING_SNAKE_CASE)
   lowerCamelCase__:      int			  =compute_effective_axis_dimension(
       _SCREAMING_SNAKE_CASE       , fixed_dimension=OnnxConfig.default_fixed_sequence       , num_token_to_add=_SCREAMING_SNAKE_CASE)

   # Generate dummy inputs according to compute batch and sequence
   lowerCamelCase__:      Dict			  =[""" """.join([tokenizer.unk_token]) * seq_length] * batch_size
   lowerCamelCase__:      Optional[int]			  =dict(tokenizer(_SCREAMING_SNAKE_CASE       , return_tensors=_SCREAMING_SNAKE_CASE))
   return common_inputs

 def 							SCREAMING_SNAKE_CASE_					(self				:   Tuple       , UpperCAmelCase_				:   Union[str, Any]       , UpperCAmelCase_				:   int = -1       , UpperCAmelCase_				:   Optional[Any] = -1       , UpperCAmelCase_				:   List[str] = False       , UpperCAmelCase_				:   int = None       , )       ->Mapping[str, Any]:



   '''simple docstring'''



   if self.task in ["default", "seq2seq-lm"]:
     lowerCamelCase__:      Optional[int]			  =self._generate_dummy_inputs_for_default_and_seqaseq_lm(
         _SCREAMING_SNAKE_CASE       , batch_size=_SCREAMING_SNAKE_CASE       , seq_length=_SCREAMING_SNAKE_CASE       , is_pair=_SCREAMING_SNAKE_CASE       , framework=_SCREAMING_SNAKE_CASE)

   elif self.task == "causal-lm":
     lowerCamelCase__:      Optional[int]			  =self._generate_dummy_inputs_for_causal_lm(
         _SCREAMING_SNAKE_CASE       , batch_size=_SCREAMING_SNAKE_CASE       , seq_length=_SCREAMING_SNAKE_CASE       , is_pair=_SCREAMING_SNAKE_CASE       , framework=_SCREAMING_SNAKE_CASE)
   else:
     lowerCamelCase__:      Tuple			  =self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
         _SCREAMING_SNAKE_CASE       , batch_size=_SCREAMING_SNAKE_CASE       , seq_length=_SCREAMING_SNAKE_CASE       , is_pair=_SCREAMING_SNAKE_CASE       , framework=_SCREAMING_SNAKE_CASE)

   return common_inputs







 def 							SCREAMING_SNAKE_CASE_					(self				:   Tuple       , UpperCAmelCase_				:   Tuple       , UpperCAmelCase_				:   Optional[int]       , UpperCAmelCase_				:   Optional[int]       , UpperCAmelCase_				:   List[Any])       ->List[Any]:



   '''simple docstring'''



   if self.task in ["default", "seq2seq-lm"]:
     lowerCamelCase__:      List[Any]			  =super()._flatten_past_key_values_(_SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE)
   else:
     lowerCamelCase__:      Dict			  =super(_SCREAMING_SNAKE_CASE       , self)._flatten_past_key_values_(
         _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE       , _SCREAMING_SNAKE_CASE)






"""simple docstring"""
from collections import defaultdict
from math import ceil, sqrt

def       _snake_case						(						UpperCamelCase						:		int = 1000000			,		UpperCamelCase						:		int = 10						):
 UpperCAmelCase	:					defaultdict	=	defaultdict(UpperCamelCase						)

 for outer_width in range(3			,		(t_limit // 4) + 2						):
  if outer_width * outer_width > t_limit:
   UpperCAmelCase	:					str	=	max(
       ceil(sqrt(outer_width * outer_width - t_limit						)						)			,		1						)
  else:
   UpperCAmelCase	:					Optional[Any]	=	1

  hole_width_lower_bound += (outer_width - hole_width_lower_bound) % 2

  for hole_width in range(UpperCamelCase			,		outer_width - 1			,		2						):
   count[outer_width * outer_width - hole_width * hole_width] += 1

 return sum(1 for n in count.values() if 1 <= n <= 10						)


if __name__ == "__main__":
      print(f"""{solution() = }""")
