





from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import TensorType, is_torch_available, logging


_lowerCamelCase :    List[Any]  							= logging.get_logger(__name__)

_lowerCamelCase :    int  							= {
    '''Helsinki-NLP/opus-mt-en-de''': '''https://huggingface.co/Helsinki-NLP/opus-mt-en-de/resolve/main/config.json''',
    # See all Marian models at https://huggingface.co/models?filter=marian
}


class 						lowerCamelCase       (__lowerCamelCase      ):







							"""simple docstring"""




							UpperCAmelCase_      						=   "marian"
							UpperCAmelCase_      						=   ["past_key_values"]
							UpperCAmelCase_      						=   {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}






							def __init__( self     :					int,			_UpperCAmelCase     :					str=5_8_1_0_1,			_UpperCAmelCase     :					Dict=None,			_UpperCAmelCase     :					Optional[Any]=1_0_2_4,			_UpperCAmelCase     :					Dict=1_2,			_UpperCAmelCase     :					str=4_0_9_6,			_UpperCAmelCase     :					List[str]=1_6,			_UpperCAmelCase     :					str=1_2,			_UpperCAmelCase     :					List[str]=4_0_9_6,			_UpperCAmelCase     :					Union[str, Any]=1_6,			_UpperCAmelCase     :					int=0.0,			_UpperCAmelCase     :					int=0.0,			_UpperCAmelCase     :					str=True,			_UpperCAmelCase     :					List[str]=True,			_UpperCAmelCase     :					Optional[Any]="gelu",			_UpperCAmelCase     :					int=1_0_2_4,			_UpperCAmelCase     :					int=0.1,			_UpperCAmelCase     :					Any=0.0,			_UpperCAmelCase     :					str=0.0,			_UpperCAmelCase     :					Optional[Any]=0.02,			_UpperCAmelCase     :					List[str]=5_8_1_0_0,			_UpperCAmelCase     :					int=False,			_UpperCAmelCase     :					List[str]=5_8_1_0_0,			_UpperCAmelCase     :					Any=0,			_UpperCAmelCase     :					int=0,			_UpperCAmelCase     :					Optional[Any]=True,			**_UpperCAmelCase     :					Optional[int],			)				->			Union[str, Any]:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						vocab_size
														SCREAMING_SNAKE_CASE__       :      str     =						decoder_vocab_size or vocab_size
														SCREAMING_SNAKE_CASE__       :      str     =						max_position_embeddings
														SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						d_model
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						encoder_ffn_dim
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						encoder_layers
														SCREAMING_SNAKE_CASE__       :      Tuple     =						encoder_attention_heads
														SCREAMING_SNAKE_CASE__       :      List[str]     =						decoder_ffn_dim
														SCREAMING_SNAKE_CASE__       :      Tuple     =						decoder_layers
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						decoder_attention_heads
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						dropout
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						attention_dropout
														SCREAMING_SNAKE_CASE__       :      int     =						activation_dropout
														SCREAMING_SNAKE_CASE__       :      List[str]     =						activation_function
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						init_std
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						encoder_layerdrop
														SCREAMING_SNAKE_CASE__       :      str     =						decoder_layerdrop
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						use_cache
														SCREAMING_SNAKE_CASE__       :      Optional[Any]     =						encoder_layers
														SCREAMING_SNAKE_CASE__       :      str     =						scale_embedding  # scale factor will be sqrt(d_model) if True
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						share_encoder_decoder_embeddings
														super().__init__(
														    pad_token_id=_UpperCAmelCase,			eos_token_id=_UpperCAmelCase,			is_encoder_decoder=_UpperCAmelCase,			decoder_start_token_id=_UpperCAmelCase,			forced_eos_token_id=_UpperCAmelCase,			**_UpperCAmelCase,			)


class 						lowerCamelCase       (__lowerCamelCase      ):







							"""simple docstring"""




							@property
							# Copied from transformers.models.bart.configuration_bart.BartOnnxConfig.inputs
							def  A_     ( self     :					Any						)				->			Mapping[str, Mapping[int, str]]:





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

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

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





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






							def  A_     ( self     :					Tuple,			_UpperCAmelCase     :					PreTrainedTokenizer,			_UpperCAmelCase     :					int = -1,			_UpperCAmelCase     :					int = -1,			_UpperCAmelCase     :					bool = False,			_UpperCAmelCase     :					Optional[TensorType] = None,			)				->			Mapping[str, Any]:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Any     =						self._generate_dummy_inputs_for_encoder_and_decoder(
														    _UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase						)

														# Generate decoder inputs
														SCREAMING_SNAKE_CASE__       :      Any     =						seq_length if not self.use_past else 1
														SCREAMING_SNAKE_CASE__       :      int     =						self._generate_dummy_inputs_for_encoder_and_decoder(
														    _UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase						)
														SCREAMING_SNAKE_CASE__       :      str     =						{F'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
														SCREAMING_SNAKE_CASE__       :      Dict     =						dict(**_UpperCAmelCase,			**_UpperCAmelCase						)

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

																					SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						torch.cat(
																					    [common_inputs["decoder_attention_mask"], torch.ones(_UpperCAmelCase,			_UpperCAmelCase						)],			dim=1						)

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

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






							def  A_     ( self     :					List[Any],			_UpperCAmelCase     :					PreTrainedTokenizer,			_UpperCAmelCase     :					int = -1,			_UpperCAmelCase     :					int = -1,			_UpperCAmelCase     :					bool = False,			_UpperCAmelCase     :					Optional[TensorType] = None,			)				->			Mapping[str, Any]:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Tuple     =						self._generate_dummy_inputs_for_encoder_and_decoder(
														    _UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase						)

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

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






							def  A_     ( self     :					Dict,			_UpperCAmelCase     :					PreTrainedTokenizer,			_UpperCAmelCase     :					int = -1,			_UpperCAmelCase     :					int = -1,			_UpperCAmelCase     :					bool = False,			_UpperCAmelCase     :					Optional[TensorType] = None,			)				->			Mapping[str, Any]:





														"""simple docstring"""
														SCREAMING_SNAKE_CASE__       :      Any     =						compute_effective_axis_dimension(
														    _UpperCAmelCase,			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
														SCREAMING_SNAKE_CASE__       :      Dict     =						tokenizer.num_special_tokens_to_add(_UpperCAmelCase						)
														SCREAMING_SNAKE_CASE__       :      List[str]     =						compute_effective_axis_dimension(
														    _UpperCAmelCase,			fixed_dimension=OnnxConfig.default_fixed_sequence,			num_token_to_add=_UpperCAmelCase						)

														# Generate dummy inputs according to compute batch and sequence
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						[" ".join([tokenizer.unk_token]						) * seq_length] * batch_size
														SCREAMING_SNAKE_CASE__       :      List[str]     =						dict(tokenizer(_UpperCAmelCase,			return_tensors=_UpperCAmelCase						)						)
														return common_inputs






							def  A_     ( self     :					Optional[int],			_UpperCAmelCase     :					PreTrainedTokenizer,			_UpperCAmelCase     :					int = -1,			_UpperCAmelCase     :					int = -1,			_UpperCAmelCase     :					bool = False,			_UpperCAmelCase     :					Optional[TensorType] = None,			)				->			Mapping[str, Any]:





														"""simple docstring"""
														if self.task in ["default", "seq2seq-lm"]:
																					SCREAMING_SNAKE_CASE__       :      str     =						self._generate_dummy_inputs_for_default_and_seqaseq_lm(
																					    _UpperCAmelCase,			batch_size=_UpperCAmelCase,			seq_length=_UpperCAmelCase,			is_pair=_UpperCAmelCase,			framework=_UpperCAmelCase						)

														else:
																					SCREAMING_SNAKE_CASE__       :      Any     =						self._generate_dummy_inputs_for_causal_lm(
																					    _UpperCAmelCase,			batch_size=_UpperCAmelCase,			seq_length=_UpperCAmelCase,			is_pair=_UpperCAmelCase,			framework=_UpperCAmelCase						)

														return common_inputs






							def  A_     ( self     :					Optional[Any],			_UpperCAmelCase     :					Any,			_UpperCAmelCase     :					Any,			_UpperCAmelCase     :					Union[str, Any],			_UpperCAmelCase     :					List[Any]						)				->			Optional[int]:





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






							@property
							def  A_     ( self     :					Any						)				->			float:





														"""simple docstring"""
														return 1E-4













def _a (  SCREAMING_SNAKE_CASE__      :  int = 50_00_00_00       )	->    int:

							'''simple docstring'''






							SCREAMING_SNAKE_CASE__       :      str     =						set()
							SCREAMING_SNAKE_CASE__       :      Dict     =						int((limit - 24) ** (1 / 2)       )

							SCREAMING_SNAKE_CASE__       :      Any     =						set(range(3			,				prime_square_limit + 1			,				2       )       )
							primes.add(2       )
							for p in range(3			,				prime_square_limit + 1			,				2       ):
														if p not in primes:
																					continue
														primes.difference_update(set(range(p * p			,				prime_square_limit + 1			,				SCREAMING_SNAKE_CASE__       )       )       )

							for primea in primes:
														SCREAMING_SNAKE_CASE__       :      Optional[int]     =						primea * primea
														for primea in primes:
																					SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						primea * primea * primea
																					if square + cube >= limit - 16:
																												break
																					for primea in primes:
																												SCREAMING_SNAKE_CASE__       :      List[str]     =						primea * primea * primea * primea
																												SCREAMING_SNAKE_CASE__       :      Optional[int]     =						square + cube + tetr
																												if total >= limit:
																																			break
																												ret.add(SCREAMING_SNAKE_CASE__       )

							return len(SCREAMING_SNAKE_CASE__       )


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






