




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


UpperCamelCase__  =		logging.get_logger(__name__)

UpperCamelCase__  =		{
    '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        __SCREAMING_SNAKE_CASE							(	lowerCamelCase						):
					_lowerCamelCase							=				"""blenderbot"""
					_lowerCamelCase							=				["""past_key_values"""]
					_lowerCamelCase							=				{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}

					def __init__(       self				, __lowercase=8_008				, __lowercase=128				, __lowercase=2				, __lowercase=10_240				, __lowercase=32				, __lowercase=24				, __lowercase=10_240				, __lowercase=32				, __lowercase=0.0				, __lowercase=0.0				, __lowercase=True				, __lowercase=True				, __lowercase="gelu"				, __lowercase=2_560				, __lowercase=0.1				, __lowercase=0.0				, __lowercase=0.0				, __lowercase=0.02				, __lowercase=1				, __lowercase=False				, __lowercase=0				, __lowercase=1				, __lowercase=2				, __lowercase=3				, __lowercase=2				, **__lowercase				, ):







						'''simple docstring'''




						lowerCamelCase_							:	List[str]							     =							vocab_size
						lowerCamelCase_							:	Optional[Any]							     =							max_position_embeddings
						lowerCamelCase_							:	List[str]							     =							d_model
						lowerCamelCase_							:	Any							     =							encoder_ffn_dim
						lowerCamelCase_							:	Tuple							     =							encoder_layers
						lowerCamelCase_							:	List[str]							     =							encoder_attention_heads
						lowerCamelCase_							:	Any							     =							decoder_ffn_dim
						lowerCamelCase_							:	Any							     =							decoder_layers
						lowerCamelCase_							:	List[str]							     =							decoder_attention_heads
						lowerCamelCase_							:	List[Any]							     =							dropout
						lowerCamelCase_							:	Any							     =							attention_dropout
						lowerCamelCase_							:	Any							     =							activation_dropout
						lowerCamelCase_							:	Union[str, Any]							     =							activation_function
						lowerCamelCase_							:	List[Any]							     =							init_std
						lowerCamelCase_							:	int							     =							encoder_layerdrop
						lowerCamelCase_							:	Any							     =							decoder_layerdrop
						lowerCamelCase_							:	Union[str, Any]							     =							use_cache
						lowerCamelCase_							:	List[Any]							     =							encoder_layers
						lowerCamelCase_							:	List[str]							     =							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        __SCREAMING_SNAKE_CASE							(	lowerCamelCase						):

					@property
					def 			lowercase_							(       self      ):







						'''simple docstring'''




						if self.task in ["default", "seq2seq-lm"]:
							lowerCamelCase_							:	Tuple							     =							OrderedDict(
							    [
							        ('input_ids', {0: 'batch', 1: 'encoder_sequence'}),
							        ('attention_mask', {0: 'batch', 1: 'encoder_sequence'}),
							    ]      )
							if self.use_past:
								lowerCamelCase_							:	List[Any]							     =							{0: 'batch'}
								lowerCamelCase_							:	Any							     =							{0: 'batch', 1: 'past_decoder_sequence + sequence'}
							else:
								lowerCamelCase_							:	Optional[Any]							     =							{0: 'batch', 1: 'decoder_sequence'}
								lowerCamelCase_							:	Union[str, Any]							     =							{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_     ,    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'}
						else:
							lowerCamelCase_							:	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      ):







						'''simple docstring'''




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

					def 			lowercase_							(       self				, __lowercase				, __lowercase = -1				, __lowercase = -1				, __lowercase = False				, __lowercase = None				, ):







						'''simple docstring'''




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







						'''simple docstring'''




						lowerCamelCase_							:	List[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_     ,    lowerCamelCase_							:	Any							     =							common_inputs['input_ids'].shape
							lowerCamelCase_							:	Tuple							     =							seqlen
							lowerCamelCase_     ,    lowerCamelCase_							:	Optional[Any]							     =							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_							:	int							     =							common_inputs['attention_mask'].dtype
							lowerCamelCase_							:	Optional[int]							     =							torch.cat(
							    [common_inputs['attention_mask'], torch.ones(__lowercase				, __lowercase				, dtype=__lowercase      )]				, dim=1      )
							lowerCamelCase_							:	Dict							     =							[
							    (torch.zeros(__lowercase      ), torch.zeros(__lowercase      )) for _ in range(__lowercase      )
							]
						return common_inputs

					def 			lowercase_							(       self				, __lowercase				, __lowercase = -1				, __lowercase = -1				, __lowercase = False				, __lowercase = None				, ):







						'''simple docstring'''




						lowerCamelCase_							:	Optional[int]							     =							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_							:	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_							:	Optional[Any]							     =							[' '.join([tokenizer.unk_token]      ) * seq_length] * batch_size
						lowerCamelCase_							:	str							     =							dict(tokenizer(__lowercase				, return_tensors=__lowercase      )      )
						return common_inputs

					def 			lowercase_							(       self				, __lowercase				, __lowercase = -1				, __lowercase = -1				, __lowercase = False				, __lowercase = None				, ):







						'''simple docstring'''




						if self.task in ["default", "seq2seq-lm"]:
							lowerCamelCase_							:	Optional[int]							     =							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_							:	Optional[int]							     =							self._generate_dummy_inputs_for_causal_lm(
							    __lowercase				, batch_size=__lowercase				, seq_length=__lowercase				, is_pair=__lowercase				, framework=__lowercase      )
						else:
							lowerCamelCase_							:	int							     =							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				, __lowercase				, __lowercase				, __lowercase				, __lowercase      ):







						'''simple docstring'''




						if self.task in ["default", "seq2seq-lm"]:
							lowerCamelCase_							:	Optional[int]							     =							super()._flatten_past_key_values_(__lowercase				, __lowercase				, __lowercase				, __lowercase      )
						else:
							lowerCamelCase_							:	Tuple							     =							super(__lowercase				, self      )._flatten_past_key_values_(
							    __lowercase				, __lowercase				, __lowercase				, __lowercase      )





					def 			lowercase_							(       self				, __lowercase				, __lowercase      ):







						'''simple docstring'''




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

						lowerCamelCase_							:	Any							     =							'past_key_values' if direction == 'inputs' else 'present'
						lowerCamelCase_     ,    lowerCamelCase_							:	Union[str, Any]							     =							self.num_layers

						lowerCamelCase_							:	Any							     =							'past_encoder_sequence'
						lowerCamelCase_							:	Union[str, Any]							     =							'past_decoder_sequence' if direction == 'inputs' else 'past_decoder_sequence + sequence'

						for i in range(__lowercase      ):
							lowerCamelCase_							:	Tuple							     =							{0: 'batch', 2: decoder_sequence}
							lowerCamelCase_							:	Tuple							     =							{0: 'batch', 2: decoder_sequence}
							lowerCamelCase_							:	Tuple							     =							{0: 'batch', 2: encoder_sequence}
							lowerCamelCase_							:	Optional[Any]							     =							{0: 'batch', 2: encoder_sequence}






def       snake_case      (							A = 998001    )							->							int:




	'''simple docstring'''


	for number in range(n - 1		,     9999		,     -1    ):
		lowerCamelCase_							:	Tuple							     =							str(A    )

		# checks whether 'str_number' is a palindrome.
		if str_number == str_number[::-1]:
			lowerCamelCase_							:	Tuple							     =							999

			# if 'number' is a product of two 3-digit numbers
			# then number is the answer otherwise fetch next number.
			while divisor != 99:
				if (number % divisor == 0) and (len(str(number // divisor    )    ) == 3.0):
					return number
				divisor -= 1
	raise ValueError('That number is larger than our acceptable range.'    )


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