

"""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


__A		     =    logging.get_logger(__name__)

__A		     =    {
    "facebook/blenderbot-3B": "https://huggingface.co/facebook/blenderbot-3B/resolve/main/config.json",
    # See all Blenderbot models at https://huggingface.co/models?filter=blenderbot
}





class 					snake_case			(       __UpperCAmelCase						):
				SCREAMING_SNAKE_CASE_     :   Optional[Any]        =						"""blenderbot"""
				SCREAMING_SNAKE_CASE_     :   str        =						["""past_key_values"""]
				SCREAMING_SNAKE_CASE_     :   Optional[Any]        =						{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}

				def __init__(			self							:       Dict  ,						UpperCamelCase__							:       List[Any]=8_0_0_8  ,						UpperCamelCase__							:       Tuple=1_2_8  ,						UpperCamelCase__							:       Tuple=2  ,						UpperCamelCase__							:       Optional[int]=1_0_2_4_0  ,						UpperCamelCase__							:       Union[str, Any]=3_2  ,						UpperCamelCase__							:       str=2_4  ,						UpperCamelCase__							:       List[Any]=1_0_2_4_0  ,						UpperCamelCase__							:       Optional[Any]=3_2  ,						UpperCamelCase__							:       List[str]=0.0  ,						UpperCamelCase__							:       Union[str, Any]=0.0  ,						UpperCamelCase__							:       str=True  ,						UpperCamelCase__							:       str=True  ,						UpperCamelCase__							:       Any="gelu"  ,						UpperCamelCase__							:       Any=2_5_6_0  ,						UpperCamelCase__							:       Optional[Any]=0.1  ,						UpperCamelCase__							:       Any=0.0  ,						UpperCamelCase__							:       List[str]=0.0  ,						UpperCamelCase__							:       Any=0.02  ,						UpperCamelCase__							:       int=1  ,						UpperCamelCase__							:       Optional[int]=False  ,						UpperCamelCase__							:       List[str]=0  ,						UpperCamelCase__							:       Tuple=1  ,						UpperCamelCase__							:       Any=2  ,						UpperCamelCase__							:       List[str]=3  ,						UpperCamelCase__							:       Any=2  ,						**UpperCamelCase__							:       List[Any]  ,						)->     Optional[Any]:



						'''simple docstring'''


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

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





class 					snake_case			(       __UpperCAmelCase						):

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



						'''simple docstring'''


						if self.task in ["default", "seq2seq-lm"]:
								__lowerCAmelCase: Optional[int]					   =    OrderedDict(
								    [
								        ("input_ids", {0: "batch", 1: "encoder_sequence"}),
								        ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
								    ])
								if self.use_past:
										__lowerCAmelCase: str					   =    {0: '''batch'''}
										__lowerCAmelCase: str					   =    {0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
								else:
										__lowerCAmelCase: List[str]					   =    {0: '''batch''', 1: '''decoder_sequence'''}
										__lowerCAmelCase: str					   =    {0: '''batch''', 1: '''decoder_sequence'''}
								if self.use_past:
										self.fill_with_past_key_values_(lowercase_  ,						direction="inputs")
						elif self.task == "causal-lm":
								__lowerCAmelCase: Dict					   =    OrderedDict(
								    [
								        ("input_ids", {0: "batch", 1: "encoder_sequence"}),
								        ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
								    ])
								if self.use_past:
										__lowerCAmelCase: List[str]					   =    self.num_layers
										for i in range(lowercase_):
												__lowerCAmelCase: str					   =    {0: '''batch''', 2: '''past_sequence + sequence'''}
												__lowerCAmelCase: List[Any]					   =    {0: '''batch''', 2: '''past_sequence + sequence'''}
						else:
								__lowerCAmelCase: Optional[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
				# Copied from transformers.models.bart.configuration_bart.BartOnnxConfig.outputs
				def 							lowercase_  (			self							:       Optional[Any])->     Mapping[str, Mapping[int, str]]:



						'''simple docstring'''


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

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



						'''simple docstring'''


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

								for _ in range(lowercase_):
										common_inputs["past_key_values"].append(
										    (
										        torch.zeros(lowercase_),
										        torch.zeros(lowercase_),
										        torch.zeros(lowercase_),
										        torch.zeros(lowercase_),
										    ))
						return common_inputs

				def 							lowercase_  (			self							:       Optional[int]  ,						UpperCamelCase__							:       Dict  ,						UpperCamelCase__							:       Union[str, Any] = -1  ,						UpperCamelCase__							:       List[Any] = -1  ,						UpperCamelCase__							:       str = False  ,						UpperCamelCase__							:       int = None  ,						)->     Mapping[str, Any]:



						'''simple docstring'''


						__lowerCAmelCase: Optional[Any]					   =    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
								__lowerCAmelCase: Optional[int]					   =    common_inputs['''input_ids'''].shape
								__lowerCAmelCase: List[Any]					   =    seqlen
								__lowerCAmelCase: List[Any]					   =    self.num_layers
								__lowerCAmelCase: str					   =    self.num_attention_heads
								__lowerCAmelCase: List[str]					   =    (
								    batch,
								    num_encoder_attention_heads,
								    past_key_values_length,
								    self._config.hidden_size // num_encoder_attention_heads,
								)
								__lowerCAmelCase: str					   =    common_inputs['''attention_mask'''].dtype
								__lowerCAmelCase: List[str]					   =    torch.cat(
								    [common_inputs["attention_mask"], torch.ones(lowercase_  ,						lowercase_  ,						dtype=lowercase_)]  ,						dim=1)
								__lowerCAmelCase: Union[str, Any]					   =    [
								    (torch.zeros(lowercase_), torch.zeros(lowercase_)) for _ in range(lowercase_)
								]
						return common_inputs

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



						'''simple docstring'''


						__lowerCAmelCase: List[str]					   =    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
						__lowerCAmelCase: int					   =    tokenizer.num_special_tokens_to_add(lowercase_)
						__lowerCAmelCase: Optional[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
						__lowerCAmelCase: int					   =    [''' '''.join([tokenizer.unk_token]) * seq_length] * batch_size
						__lowerCAmelCase: str					   =    dict(tokenizer(lowercase_  ,						return_tensors=lowercase_))
						return common_inputs

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



						'''simple docstring'''


						if self.task in ["default", "seq2seq-lm"]:
								__lowerCAmelCase: Dict					   =    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":
								__lowerCAmelCase: Any					   =    self._generate_dummy_inputs_for_causal_lm(
								    lowercase_  ,						batch_size=lowercase_  ,						seq_length=lowercase_  ,						is_pair=lowercase_  ,						framework=lowercase_)
						else:
								__lowerCAmelCase: 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 							lowercase_  (			self							:       Optional[Any]  ,						UpperCamelCase__							:       Dict  ,						UpperCamelCase__							:       List[Any]  ,						UpperCamelCase__							:       int  ,						UpperCamelCase__							:       Optional[int])->     str:



						'''simple docstring'''


						if self.task in ["default", "seq2seq-lm"]:
								__lowerCAmelCase: Union[str, Any]					   =    super()._flatten_past_key_values_(lowercase_  ,						lowercase_  ,						lowercase_  ,						lowercase_)
						else:
								__lowerCAmelCase: Optional[Any]					   =    super(lowercase_  ,						self)._flatten_past_key_values_(
								    lowercase_  ,						lowercase_  ,						lowercase_  ,						lowercase_)




				def 							lowercase_  (			self							:       Optional[Any]  ,						UpperCamelCase__							:       int  ,						UpperCamelCase__							:       Any)->     Optional[int]:



						'''simple docstring'''


						if direction not in ["inputs", "outputs"]:
								raise ValueError(f"direction must either be \"inputs\" or \"outputs\", but {direction} was given")

						__lowerCAmelCase: List[Any]					   =    '''past_key_values''' if direction == '''inputs''' else '''present'''
						__lowerCAmelCase: str					   =    self.num_layers

						__lowerCAmelCase: Optional[int]					   =    '''past_encoder_sequence'''
						__lowerCAmelCase: Tuple					   =    '''past_decoder_sequence''' if direction == '''inputs''' else '''past_decoder_sequence + sequence'''

						for i in range(lowercase_):
								__lowerCAmelCase: List[str]					   =    {0: '''batch''', 2: decoder_sequence}
								__lowerCAmelCase: Tuple					   =    {0: '''batch''', 2: decoder_sequence}
								__lowerCAmelCase: List[str]					   =    {0: '''batch''', 2: encoder_sequence}
								__lowerCAmelCase: Optional[int]					   =    {0: '''batch''', 2: encoder_sequence}





"""simple docstring"""


def 					a__					(					__SCREAMING_SNAKE_CASE = 1_0_0_0				)			->			int:
		__lowerCAmelCase: int					   =    0
		__lowerCAmelCase: Optional[int]					   =    0
		while 1:
				num += 3
				if num >= n:
						break
				total += num
				num += 2
				if num >= n:
						break
				total += num
				num += 1
				if num >= n:
						break
				total += num
				num += 3
				if num >= n:
						break
				total += num
				num += 1
				if num >= n:
						break
				total += num
				num += 2
				if num >= n:
						break
				total += num
				num += 3
				if num >= n:
						break
				total += num
		return total


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


