


"""simple docstring"""







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


lowerCAmelCase__      				=   logging.get_logger(__name__)

lowerCAmelCase__      				=   {
    '''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__				(		lowercase				):
       """simple docstring"""


       a  :				Optional[int]   ="blenderbot-small"
       a  :				str   =["past_key_values"]
       a  :				List[str]   ={"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}

       def __init__(						self		,     snake_case__=50_265		,     snake_case__=512		,     snake_case__=8		,     snake_case__=2_048		,     snake_case__=16		,     snake_case__=8		,     snake_case__=2_048		,     snake_case__=16		,     snake_case__=0.0		,     snake_case__=0.0		,     snake_case__=True		,     snake_case__=True		,     snake_case__="gelu"		,     snake_case__=512		,     snake_case__=0.1		,     snake_case__=0.0		,     snake_case__=0.0		,     snake_case__=0.02		,     snake_case__=1		,     snake_case__=False		,     snake_case__=0		,     snake_case__=1		,     snake_case__=2		,     snake_case__=2		,     **snake_case__		,     ):






         """simple docstring"""





         lowerCAmelCase     :     Dict								=							vocab_size
         lowerCAmelCase     :     List[Any]								=							max_position_embeddings
         lowerCAmelCase     :     Union[str, Any]								=							d_model
         lowerCAmelCase     :     List[str]								=							encoder_ffn_dim
         lowerCAmelCase     :     Optional[int]								=							encoder_layers
         lowerCAmelCase     :     str								=							encoder_attention_heads
         lowerCAmelCase     :     int								=							decoder_ffn_dim
         lowerCAmelCase     :     int								=							decoder_layers
         lowerCAmelCase     :     int								=							decoder_attention_heads
         lowerCAmelCase     :     List[Any]								=							dropout
         lowerCAmelCase     :     int								=							attention_dropout
         lowerCAmelCase     :     List[str]								=							activation_dropout
         lowerCAmelCase     :     int								=							activation_function
         lowerCAmelCase     :     str								=							init_std
         lowerCAmelCase     :     Optional[int]								=							encoder_layerdrop
         lowerCAmelCase     :     Tuple								=							decoder_layerdrop
         lowerCAmelCase     :     Dict								=							use_cache
         lowerCAmelCase     :     Any								=							encoder_layers
         lowerCAmelCase     :     Optional[Any]								=							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__				(		lowercase				):
       """simple docstring"""


       @property
       def        lowercase__							(						self						):






         """simple docstring"""





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

           if self.use_past:
             lowerCAmelCase     :     Optional[Any]								=							{0: "batch"}
             lowerCAmelCase     :     int								=							{0: "batch", 1: "past_decoder_sequence + sequence"}
           else:
             lowerCAmelCase     :     str								=							{0: "batch", 1: "decoder_sequence"}
             lowerCAmelCase     :     Any								=							{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.
           lowerCAmelCase     :     Tuple								=							OrderedDict(
               [
                   ("input_ids", {0: "batch", 1: "encoder_sequence"}),
                   ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
               ]						)
           if self.use_past:
             lowerCAmelCase						,  lowerCAmelCase     :     Union[str, Any]								=							self.num_layers
             for i in range(snake_case__						):
               lowerCAmelCase     :     List[Any]								=							{0: "batch", 2: "past_sequence + sequence"}
               lowerCAmelCase     :     Optional[int]								=							{0: "batch", 2: "past_sequence + sequence"}
         else:
           lowerCAmelCase     :     List[str]								=							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        lowercase__							(						self						):






         """simple docstring"""





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

       def        lowercase__							(						self		,     snake_case__		,     snake_case__ = -1		,     snake_case__ = -1		,     snake_case__ = False		,     snake_case__ = None		,     ):






         """simple docstring"""





         lowerCAmelCase     :     List[Any]								=							self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
             snake_case__		,     snake_case__		,     snake_case__		,     snake_case__		,     snake_case__						)

         # Generate decoder inputs
         lowerCAmelCase     :     str								=							seq_length if not self.use_past else 1
         lowerCAmelCase     :     Tuple								=							self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
             snake_case__		,     snake_case__		,     snake_case__		,     snake_case__		,     snake_case__						)
         lowerCAmelCase     :     Any								=							{f"""decoder_{name}""": tensor for name, tensor in decoder_inputs.items()}
         lowerCAmelCase     :     str								=							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
           lowerCAmelCase						,  lowerCAmelCase     :     Union[str, Any]								=							common_inputs["input_ids"].shape
           lowerCAmelCase     :     int								=							common_inputs["decoder_input_ids"].shape[1]
           lowerCAmelCase						,  lowerCAmelCase     :     str								=							self.num_attention_heads
           lowerCAmelCase     :     Dict								=							(
               batch,
               num_encoder_attention_heads,
               encoder_seq_length,
               self._config.hidden_size // num_encoder_attention_heads,
           )
           lowerCAmelCase     :     Dict								=							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     :     Dict								=							torch.cat(
               [common_inputs["decoder_attention_mask"], torch.ones(snake_case__		,     snake_case__						)]		,     dim=1						)

           lowerCAmelCase     :     Tuple								=							[]
           # If the number of encoder and decoder layers are present in the model configuration, both are considered
           lowerCAmelCase						,  lowerCAmelCase     :     str								=							self.num_layers
           lowerCAmelCase     :     Tuple								=							min(snake_case__		,     snake_case__						)
           lowerCAmelCase     :     Optional[int]								=							max(snake_case__		,     snake_case__						) - min_num_layers
           lowerCAmelCase     :     Any								=							"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.
           lowerCAmelCase     :     Any								=							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        lowercase__							(						self		,     snake_case__		,     snake_case__ = -1		,     snake_case__ = -1		,     snake_case__ = False		,     snake_case__ = None		,     ):






         """simple docstring"""





         lowerCAmelCase     :     Union[str, Any]								=							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
           lowerCAmelCase						,  lowerCAmelCase     :     Dict								=							common_inputs["input_ids"].shape
           # Not using the same length for past_key_values
           lowerCAmelCase     :     List[Any]								=							seqlen + 2
           lowerCAmelCase						,  lowerCAmelCase     :     Optional[int]								=							self.num_layers
           lowerCAmelCase						,  lowerCAmelCase     :     Tuple								=							self.num_attention_heads
           lowerCAmelCase     :     Optional[int]								=							(
               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     :     List[str]								=							torch.cat(
               [common_inputs["attention_mask"], torch.ones(snake_case__		,     snake_case__		,     dtype=snake_case__						)]		,     dim=1						)
           lowerCAmelCase     :     Union[str, Any]								=							[
               (torch.zeros(snake_case__						), torch.zeros(snake_case__						)) for _ in range(snake_case__						)
           ]
         return common_inputs

       def        lowercase__							(						self		,     snake_case__		,     snake_case__ = -1		,     snake_case__ = -1		,     snake_case__ = False		,     snake_case__ = None		,     ):






         """simple docstring"""





         lowerCAmelCase     :     Optional[int]								=							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
         lowerCAmelCase     :     Any								=							tokenizer.num_special_tokens_to_add(snake_case__						)
         lowerCAmelCase     :     str								=							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
         lowerCAmelCase     :     List[Any]								=							[" ".join([tokenizer.unk_token]						) * seq_length] * batch_size
         lowerCAmelCase     :     Tuple								=							dict(tokenizer(snake_case__		,     return_tensors=snake_case__						)						)
         return common_inputs

       def        lowercase__							(						self		,     snake_case__		,     snake_case__ = -1		,     snake_case__ = -1		,     snake_case__ = False		,     snake_case__ = None		,     ):






         """simple docstring"""





         if self.task in ["default", "seq2seq-lm"]:
           lowerCAmelCase     :     List[str]								=							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":
           lowerCAmelCase     :     Union[str, Any]								=							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:
           lowerCAmelCase     :     List[str]								=							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        lowercase__							(						self		,     snake_case__		,     snake_case__		,     snake_case__		,     snake_case__						):






         """simple docstring"""





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









"""simple docstring"""







from __future__ import annotations

from functools import lru_cache
from math import ceil

lowerCAmelCase__      				=   100

lowerCAmelCase__      				=   set(range(3, NUM_PRIMES, 2))
primes.add(2)
lowerCAmelCase__      				=   42

for prime in range(3, ceil(NUM_PRIMES**0.5), 2):
     if prime not in primes:
          continue
     primes.difference_update(set(range(prime * prime, NUM_PRIMES, prime)))
@lru_cache(maxsize=1_0_0				)
def 					a__			(				SCREAMING_SNAKE_CASE    :    int				):


  '''simple docstring'''







  if number_to_partition < 0:
    return set()
  elif number_to_partition == 0:
    return {1}

  lowerCAmelCase     :     set[int]								=							set()
  lowerCAmelCase     :     int
  lowerCAmelCase     :     int

  for prime in primes:
    if prime > number_to_partition:
      continue
    for sub in partition(number_to_partition - prime				):
      ret.add(sub * prime				)

  return ret
def 					a__			(				SCREAMING_SNAKE_CASE    :    int = 5_0_0_0				):


  '''simple docstring'''







  for number_to_partition in range(1				,      SCREAMING_SNAKE_CASE				):
    if len(partition(SCREAMING_SNAKE_CASE				)				) > number_unique_partitions:
      return number_to_partition
  return None


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





