code: 
  
  
  '''simple docstring'''
  
  
  
  
  
  from collections import OrderedDict
  from typing import Any, Mapping, Optional
  
  from ... import PreTrainedTokenizer
  from ...configuration_utils import PretrainedConfig
  from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast
  from ...onnx.utils import compute_effective_axis_dimension
  from ...utils import TensorType, is_torch_available, logging
  
  
  lowerCAmelCase__   	=				logging.get_logger(__name__)
  
  lowerCAmelCase__   	=				{
      'facebook/m2m100_418M': 'https://huggingface.co/facebook/m2m100_418M/resolve/main/config.json',
      # See all M2M100 models at https://huggingface.co/models?filter=m2m_100
  }
  
  
  
  
  
  
  
  class   lowerCAmelCase__ (       __SCREAMING_SNAKE_CASE):
  
  
  
  
       '''simple docstring'''
       __SCREAMING_SNAKE_CASE						    =				"m2m_100"
       __SCREAMING_SNAKE_CASE						    =				["past_key_values"]
       __SCREAMING_SNAKE_CASE						    =				{"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}
  
  
       def __init__(		self				,		__lowerCamelCase=1_2_8_1_1_2				,		__lowerCamelCase=1_0_2_4				,		__lowerCamelCase=1_2				,		__lowerCamelCase=4_0_9_6				,		__lowerCamelCase=1_6				,		__lowerCamelCase=1_2				,		__lowerCamelCase=4_0_9_6				,		__lowerCamelCase=1_6				,		__lowerCamelCase=0.0_5				,		__lowerCamelCase=0.0_5				,		__lowerCamelCase=True				,		__lowerCamelCase=True				,		__lowerCamelCase="relu"				,		__lowerCamelCase=1_0_2_4				,		__lowerCamelCase=0.1				,		__lowerCamelCase=0.1				,		__lowerCamelCase=0.0				,		__lowerCamelCase=0.0_2				,		__lowerCamelCase=2				,		__lowerCamelCase=True				,		__lowerCamelCase=1				,		__lowerCamelCase=0				,		__lowerCamelCase=2				,		**__lowerCamelCase				,		)    ->       Any:
              _A   : Dict       					=				vocab_size
              _A   : List[str]       					=				max_position_embeddings
              _A   : List[Any]       					=				d_model
              _A   : List[Any]       					=				encoder_ffn_dim
              _A   : Optional[Any]       					=				encoder_layers
              _A   : List[str]       					=				encoder_attention_heads
              _A   : str       					=				decoder_ffn_dim
              _A   : List[Any]       					=				decoder_layers
              _A   : Any       					=				decoder_attention_heads
              _A   : Dict       					=				dropout
              _A   : Union[str, Any]       					=				attention_dropout
              _A   : Tuple       					=				activation_dropout
              _A   : Tuple       					=				activation_function
              _A   : List[str]       					=				init_std
              _A   : Optional[int]       					=				encoder_layerdrop
              _A   : List[Any]       					=				decoder_layerdrop
              _A   : Optional[Any]       					=				use_cache
              _A   : Any       					=				encoder_layers
              _A   : List[Any]       					=				scale_embedding  # scale factor will be sqrt(d_model) if True
  
              super().__init__(
                  pad_token_id=UpperCamelCase__				,		bos_token_id=UpperCamelCase__				,		eos_token_id=UpperCamelCase__				,		is_encoder_decoder=UpperCamelCase__				,		decoder_start_token_id=UpperCamelCase__				,		**UpperCamelCase__				,		)
  
  
  
  
  
  
  
  class   lowerCAmelCase__ (       __SCREAMING_SNAKE_CASE):
  
  
  
  
       '''simple docstring'''
  
  
       @property
       def 				_lowerCamelCase				(		self)    ->       Mapping[str, Mapping[int, str]]:
              _A   : Dict       					=				OrderedDict(
                  [
                      ("input_ids", {0: "batch", 1: "encoder_sequence"}),
                      ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
                  ])
  
              if self.use_past:
                     _A   : Union[str, Any]       					=				{0: '''batch'''}
                     _A   : str       					=				{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
              else:
                     _A   : Tuple       					=				{0: '''batch''', 1: '''decoder_sequence'''}
                     _A   : Optional[Any]       					=				{0: '''batch''', 1: '''decoder_sequence'''}
  
              if self.use_past:
                     self.fill_with_past_key_values_(UpperCamelCase__				,		direction="inputs")
              return common_inputs
  
  
       def 				_lowerCamelCase				(		self				,		__lowerCamelCase				,		__lowerCamelCase = -1				,		__lowerCamelCase = -1				,		__lowerCamelCase = False				,		__lowerCamelCase = None				,		)    ->       Mapping[str, Any]:
              _A   : str       					=				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
              _A   : Union[str, Any]       					=				tokenizer.num_special_tokens_to_add(UpperCamelCase__)
              _A   : Optional[int]       					=				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
              _A   : Any       					=				[''' '''.join([tokenizer.unk_token]) * seq_length] * batch_size
              _A   : Union[str, Any]       					=				dict(tokenizer(UpperCamelCase__				,		return_tensors=UpperCamelCase__))
              return common_inputs
  
  
       def 				_lowerCamelCase				(		self				,		__lowerCamelCase				,		__lowerCamelCase = -1				,		__lowerCamelCase = -1				,		__lowerCamelCase = False				,		__lowerCamelCase = None				,		)    ->       Mapping[str, Any]:
              _A   : Dict       					=				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                  UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__)
  
              # Generate decoder inputs
              _A   : int       					=				seq_length if not self.use_past else 1
              _A   : Any       					=				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                  UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__				,		UpperCamelCase__)
              _A   : List[str]       					=				{F"decoder_{name}": tensor for name, tensor in decoder_inputs.items()}
              _A   : Union[str, Any]       					=				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
                     _A   : str       					=				common_inputs['''input_ids'''].shape
                     _A   : Union[str, Any]       					=				common_inputs['''decoder_input_ids'''].shape[1]
                     _A   : List[str]       					=				self.num_attention_heads
                     _A   : str       					=				(
                         batch,
                         num_encoder_attention_heads,
                         encoder_seq_length,
                         self._config.hidden_size // num_encoder_attention_heads,
                     )
                     _A   : Optional[Any]       					=				decoder_seq_length + 3
                     _A   : Tuple       					=				(
                         batch,
                         num_decoder_attention_heads,
                         decoder_past_length,
                         self._config.hidden_size // num_decoder_attention_heads,
                     )
  
                     _A   : str       					=				torch.cat(
                         [common_inputs["decoder_attention_mask"], torch.ones(UpperCamelCase__				,		UpperCamelCase__)]				,		dim=1)
  
                     _A   : Union[str, Any]       					=				[]
                     # If the number of encoder and decoder layers are present in the model configuration, both are considered
                     _A   : Dict       					=				self.num_layers
                     _A   : Dict       					=				min(UpperCamelCase__				,		UpperCamelCase__)
                     _A   : int       					=				max(UpperCamelCase__				,		UpperCamelCase__) - min_num_layers
                     _A   : 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.
                     _A   : int       					=				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
  
  
       __SCREAMING_SNAKE_CASE						    =				_generate_dummy_inputs_for_default_and_seqaseq_lm
  
style_context: 
  
  
  lowerCAmelCase__   	=				'\n# Transformers installation\n! pip install transformers datasets evaluate\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n'
  
  lowerCAmelCase__   	=				[{'type': 'code', 'content': INSTALL_CONTENT}]
  lowerCAmelCase__   	=				{
      '{processor_class}': 'FakeProcessorClass',
      '{model_class}': 'FakeModelClass',
      '{object_class}': 'FakeObjectClass',
  }
  