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


_SCREAMING_SNAKE_CASE 		=      logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE 		=      {
    "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_		(      __lowerCAmelCase		):
   __lowerCAmelCase           =				"""blenderbot-small"""
   __lowerCAmelCase           =				["""past_key_values"""]
   __lowerCAmelCase           =				{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}







   def __init__(     self						:						int   ,   lowerCamelCase_						:						Tuple=5_0265   ,   lowerCamelCase_						:						Dict=512   ,   lowerCamelCase_						:						int=8   ,   lowerCamelCase_						:						Dict=2048   ,   lowerCamelCase_						:						int=16   ,   lowerCamelCase_						:						int=8   ,   lowerCamelCase_						:						int=2048   ,   lowerCamelCase_						:						str=16   ,   lowerCamelCase_						:						List[Any]=0.0   ,   lowerCamelCase_						:						Union[str, Any]=0.0   ,   lowerCamelCase_						:						Any=True   ,   lowerCamelCase_						:						str=True   ,   lowerCamelCase_						:						List[Any]="gelu"   ,   lowerCamelCase_						:						Any=512   ,   lowerCamelCase_						:						Dict=0.1   ,   lowerCamelCase_						:						Any=0.0   ,   lowerCamelCase_						:						Dict=0.0   ,   lowerCamelCase_						:						Optional[Any]=0.0_2   ,   lowerCamelCase_						:						int=1   ,   lowerCamelCase_						:						List[Any]=False   ,   lowerCamelCase_						:						List[Any]=0   ,   lowerCamelCase_						:						Union[str, Any]=1   ,   lowerCamelCase_						:						int=2   ,   lowerCamelCase_						:						List[str]=2   ,   **lowerCamelCase_						:						List[str]   ,   ):





    """simple docstring"""


    UpperCamelCase			  =      vocab_size
    UpperCamelCase			  =      max_position_embeddings
    UpperCamelCase			  =      d_model
    UpperCamelCase			  =      encoder_ffn_dim
    UpperCamelCase			  =      encoder_layers
    UpperCamelCase			  =      encoder_attention_heads
    UpperCamelCase			  =      decoder_ffn_dim
    UpperCamelCase			  =      decoder_layers
    UpperCamelCase			  =      decoder_attention_heads
    UpperCamelCase			  =      dropout
    UpperCamelCase			  =      attention_dropout
    UpperCamelCase			  =      activation_dropout
    UpperCamelCase			  =      activation_function
    UpperCamelCase			  =      init_std
    UpperCamelCase			  =      encoder_layerdrop
    UpperCamelCase			  =      decoder_layerdrop
    UpperCamelCase			  =      use_cache
    UpperCamelCase			  =      encoder_layers
    UpperCamelCase			  =      scale_embedding  # scale factor will be sqrt(d_model) if True

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





class SCREAMING_SNAKE_CASE_		(      __lowerCAmelCase		):







   @property
   def 						lowerCamelCase_	(     self						:						Tuple				):





    """simple docstring"""


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

     if self.use_past:
      UpperCamelCase			  =      {0: """batch"""}
      UpperCamelCase			  =      {0: """batch""", 1: """past_decoder_sequence + sequence"""}
     else:
      UpperCamelCase			  =      {0: """batch""", 1: """decoder_sequence"""}
      UpperCamelCase			  =      {0: """batch""", 1: """decoder_sequence"""}

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





    """simple docstring"""


    if self.task in ["default", "seq2seq-lm"]:
     UpperCamelCase			  =      super().outputs
    else:
     UpperCamelCase			  =      super(snake_case__   ,   self				).outputs
     if self.use_past:
      UpperCamelCase  ,     UpperCamelCase			  =      self.num_layers
      for i in range(snake_case__				):
       UpperCamelCase			  =      {0: """batch""", 2: """past_sequence + sequence"""}
       UpperCamelCase			  =      {0: """batch""", 2: """past_sequence + sequence"""}
    return common_outputs







   def 						lowerCamelCase_	(     self						:						int   ,   lowerCamelCase_						:						PreTrainedTokenizer   ,   lowerCamelCase_						:						int = -1   ,   lowerCamelCase_						:						int = -1   ,   lowerCamelCase_						:						bool = False   ,   lowerCamelCase_						:						Optional[TensorType] = None   ,   ):





    """simple docstring"""


    UpperCamelCase			  =      self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
        snake_case__   ,   snake_case__   ,   snake_case__   ,   snake_case__   ,   snake_case__				)

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

     UpperCamelCase			  =      torch.cat(
         [common_inputs["""decoder_attention_mask"""], torch.ones(snake_case__   ,   snake_case__				)]   ,   dim=1				)

     UpperCamelCase			  =      []
     # If the number of encoder and decoder layers are present in the model configuration, both are considered
     UpperCamelCase  ,     UpperCamelCase			  =      self.num_layers
     UpperCamelCase			  =      min(snake_case__   ,   snake_case__				)
     UpperCamelCase			  =      max(snake_case__   ,   snake_case__				) - min_num_layers
     UpperCamelCase			  =      """encoder""" if num_encoder_layers > num_decoder_layers else """decoder"""

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







   def 						lowerCamelCase_	(     self						:						str   ,   lowerCamelCase_						:						PreTrainedTokenizer   ,   lowerCamelCase_						:						int = -1   ,   lowerCamelCase_						:						int = -1   ,   lowerCamelCase_						:						bool = False   ,   lowerCamelCase_						:						Optional[TensorType] = None   ,   ):





    """simple docstring"""


    UpperCamelCase			  =      self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
        snake_case__   ,   snake_case__   ,   snake_case__   ,   snake_case__   ,   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
     UpperCamelCase  ,     UpperCamelCase			  =      common_inputs["""input_ids"""].shape
     # Not using the same length for past_key_values
     UpperCamelCase			  =      seqlen + 2
     UpperCamelCase  ,     UpperCamelCase			  =      self.num_layers
     UpperCamelCase  ,     UpperCamelCase			  =      self.num_attention_heads
     UpperCamelCase			  =      (
         batch,
         num_encoder_attention_heads,
         past_key_values_length,
         self._config.hidden_size // num_encoder_attention_heads,
     )

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







   def 						lowerCamelCase_	(     self						:						int   ,   lowerCamelCase_						:						PreTrainedTokenizer   ,   lowerCamelCase_						:						int = -1   ,   lowerCamelCase_						:						int = -1   ,   lowerCamelCase_						:						bool = False   ,   lowerCamelCase_						:						Optional[TensorType] = None   ,   ):





    """simple docstring"""


    UpperCamelCase			  =      compute_effective_axis_dimension(
        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
    UpperCamelCase			  =      tokenizer.num_special_tokens_to_add(snake_case__				)
    UpperCamelCase			  =      compute_effective_axis_dimension(
        snake_case__   ,   fixed_dimension=OnnxConfig.default_fixed_sequence   ,   num_token_to_add=snake_case__				)

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







   def 						lowerCamelCase_	(     self						:						List[str]   ,   lowerCamelCase_						:						PreTrainedTokenizer   ,   lowerCamelCase_						:						int = -1   ,   lowerCamelCase_						:						int = -1   ,   lowerCamelCase_						:						bool = False   ,   lowerCamelCase_						:						Optional[TensorType] = None   ,   ):





    """simple docstring"""


    if self.task in ["default", "seq2seq-lm"]:
     UpperCamelCase			  =      self._generate_dummy_inputs_for_default_and_seqaseq_lm(
         snake_case__   ,   batch_size=snake_case__   ,   seq_length=snake_case__   ,   is_pair=snake_case__   ,   framework=snake_case__				)

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

    return common_inputs







   def 						lowerCamelCase_	(     self						:						Tuple   ,   lowerCamelCase_						:						List[str]   ,   lowerCamelCase_						:						List[Any]   ,   lowerCamelCase_						:						Dict   ,   lowerCamelCase_						:						Tuple				):





    """simple docstring"""


    if self.task in ["default", "seq2seq-lm"]:
     UpperCamelCase			  =      super()._flatten_past_key_values_(snake_case__   ,   snake_case__   ,   snake_case__   ,   snake_case__				)
    else:
     UpperCamelCase			  =      super(snake_case__   ,   self				)._flatten_past_key_values_(
         snake_case__   ,   snake_case__   ,   snake_case__   ,   snake_case__				)



def 							__lowerCAmelCase     (							_UpperCamelCase		:	List[str]=2_81_23						)		->				str:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      [1] * (limit + 1)

 for i in range(2		,				int(limit**0.5						) + 1						):
  sum_divs[i * i] += i
  for k in range(i + 1		,				limit // i + 1						):
   sum_divs[k * i] += k + i

 SCREAMING_SNAKE_CASE		    =      set()
 SCREAMING_SNAKE_CASE		    =      0

 for n in range(1		,				limit + 1						):
  if sum_divs[n] > n:
   abundants.add(_UpperCamelCase						)

  if not any((n - a in abundants) for a in abundants						):
   res += n

 return res


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

