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
  
  
  __SCREAMING_SNAKE_CASE     :   Tuple					=						logging.get_logger(__name__)
  
  __SCREAMING_SNAKE_CASE     :   Optional[Any]					=						{
      """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 __snake_case		(					__lowerCamelCase      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     lowerCAmelCase_				:   str     	=			'm2m_100'
     lowerCAmelCase_				:   Any     	=			['past_key_values']
     lowerCAmelCase_				:   Union[str, Any]     	=			{'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}
  
  
  
  
     def __init__(		self							:Tuple				,  UpperCamelCase__							:Dict=128_112				,  UpperCamelCase__							:str=1_024				,  UpperCamelCase__							:Union[str, Any]=12				,  UpperCamelCase__							:int=4_096				,  UpperCamelCase__							:Optional[int]=16				,  UpperCamelCase__							:Tuple=12				,  UpperCamelCase__							:str=4_096				,  UpperCamelCase__							:int=16				,  UpperCamelCase__							:List[str]=0.05				,  UpperCamelCase__							:List[Any]=0.05				,  UpperCamelCase__							:Any=True				,  UpperCamelCase__							:List[Any]=True				,  UpperCamelCase__							:Union[str, Any]="relu"				,  UpperCamelCase__							:List[Any]=1_024				,  UpperCamelCase__							:Any=0.1				,  UpperCamelCase__							:Any=0.1				,  UpperCamelCase__							:Union[str, Any]=0.0				,  UpperCamelCase__							:List[str]=0.02				,  UpperCamelCase__							:Optional[int]=2				,  UpperCamelCase__							:List[Any]=True				,  UpperCamelCase__							:Dict=1				,  UpperCamelCase__							:Dict=0				,  UpperCamelCase__							:str=2				,  **UpperCamelCase__							:Any				,  ):
            _a          =				vocab_size
            _a          =				max_position_embeddings
            _a          =				d_model
            _a          =				encoder_ffn_dim
            _a          =				encoder_layers
            _a          =				encoder_attention_heads
            _a          =				decoder_ffn_dim
            _a          =				decoder_layers
            _a          =				decoder_attention_heads
            _a          =				dropout
            _a          =				attention_dropout
            _a          =				activation_dropout
            _a          =				activation_function
            _a          =				init_std
            _a          =				encoder_layerdrop
            _a          =				decoder_layerdrop
            _a          =				use_cache
            _a          =				encoder_layers
            _a          =				scale_embedding  # scale factor will be sqrt(d_model) if True
  
            super().__init__(
                pad_token_id=_lowerCAmelCase				,  bos_token_id=_lowerCAmelCase				,  eos_token_id=_lowerCAmelCase				,  is_encoder_decoder=_lowerCAmelCase				,  decoder_start_token_id=_lowerCAmelCase				,  **_lowerCAmelCase				,  )
  
  
  
  
  
  
  class __snake_case		(					__lowerCamelCase      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     @property
     def SCREAMING_SNAKE_CASE_      (		self							:List[str]       ):
            _a          =				OrderedDict(
                [
                    ("input_ids", {0: "batch", 1: "encoder_sequence"}),
                    ("attention_mask", {0: "batch", 1: "encoder_sequence"}),
                ]       )
  
            if self.use_past:
                   _a          =				{0: """batch"""}
                   _a          =				{0: """batch""", 1: """past_decoder_sequence + sequence"""}
            else:
                   _a          =				{0: """batch""", 1: """decoder_sequence"""}
                   _a          =				{0: """batch""", 1: """decoder_sequence"""}
  
            if self.use_past:
                   self.fill_with_past_key_values_(_lowerCAmelCase				,  direction="inputs"       )
            return common_inputs
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Any				,  UpperCamelCase__							:str				,  UpperCamelCase__							:Dict = -1				,  UpperCamelCase__							:Tuple = -1				,  UpperCamelCase__							:Optional[int] = False				,  UpperCamelCase__							:Tuple = None				,  ):
            # Copied from OnnxConfig.generate_dummy_inputs
            # Did not use super(OnnxConfigWithPast, self).generate_dummy_inputs for code clarity.
            # If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
            _a          =				compute_effective_axis_dimension(
                _lowerCAmelCase				,  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          =				tokenizer.num_special_tokens_to_add(_lowerCAmelCase       )
            _a          =				compute_effective_axis_dimension(
                _lowerCAmelCase				,  fixed_dimension=OnnxConfig.default_fixed_sequence				,  num_token_to_add=_lowerCAmelCase       )
  
            # Generate dummy inputs according to compute batch and sequence
            _a          =				[""" """.join([tokenizer.unk_token]       ) * seq_length] * batch_size
            _a          =				dict(tokenizer(_lowerCAmelCase				,  return_tensors=_lowerCAmelCase       )       )
            return common_inputs
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:str				,  UpperCamelCase__							:List[str]				,  UpperCamelCase__							:int = -1				,  UpperCamelCase__							:Optional[Any] = -1				,  UpperCamelCase__							:Optional[int] = False				,  UpperCamelCase__							:Union[str, Any] = None				,  ):
            _a          =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                _lowerCAmelCase				,  _lowerCAmelCase				,  _lowerCAmelCase				,  _lowerCAmelCase				,  _lowerCAmelCase       )
  
            # Generate decoder inputs
            _a          =				seq_length if not self.use_past else 1
            _a          =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
                _lowerCAmelCase				,  _lowerCAmelCase				,  _lowerCAmelCase				,  _lowerCAmelCase				,  _lowerCAmelCase       )
            _a          =				{f'decoder_{name}': tensor for name, tensor in decoder_inputs.items()}
            _a          =				dict(**_lowerCAmelCase				,  **_lowerCAmelCase       )
  
            if self.use_past:
                   if not is_torch_available():
                          raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed."       )
                   else:
                          import torch
                   _a          =				common_inputs["""input_ids"""].shape
                   _a          =				common_inputs["""decoder_input_ids"""].shape[1]
                   _a          =				self.num_attention_heads
                   _a          =				(
                       batch,
                       num_encoder_attention_heads,
                       encoder_seq_length,
                       self._config.hidden_size // num_encoder_attention_heads,
                   )
                   _a          =				decoder_seq_length + 3
                   _a          =				(
                       batch,
                       num_decoder_attention_heads,
                       decoder_past_length,
                       self._config.hidden_size // num_decoder_attention_heads,
                   )
  
                   _a          =				torch.cat(
                       [common_inputs["decoder_attention_mask"], torch.ones(_lowerCAmelCase				,  _lowerCAmelCase       )]				,  dim=1       )
  
                   _a          =				[]
                   # If the number of encoder and decoder layers are present in the model configuration, both are considered
                   _a          =				self.num_layers
                   _a          =				min(_lowerCAmelCase				,  _lowerCAmelCase       )
                   _a          =				max(_lowerCAmelCase				,  _lowerCAmelCase       ) - min_num_layers
                   _a          =				"""encoder""" if num_encoder_layers > num_decoder_layers else """decoder"""
  
                   for _ in range(_lowerCAmelCase       ):
                          common_inputs["past_key_values"].append(
                              (
                                  torch.zeros(_lowerCAmelCase       ),
                                  torch.zeros(_lowerCAmelCase       ),
                                  torch.zeros(_lowerCAmelCase       ),
                                  torch.zeros(_lowerCAmelCase       ),
                              )       )
                   # TODO: test this.
                   _a          =				encoder_shape if remaining_side_name == """encoder""" else decoder_shape
                   for _ in range(_lowerCAmelCase				,  _lowerCAmelCase       ):
                          common_inputs["past_key_values"].append((torch.zeros(_lowerCAmelCase       ), torch.zeros(_lowerCAmelCase       ))       )
            return common_inputs
     lowerCAmelCase_				:   Any     	=			_generate_dummy_inputs_for_default_and_seqaseq_lm
  
style_context: 
  
  
  """simple docstring"""
  
  
  
  
  from ...configuration_utils import PretrainedConfig
  from ...utils import logging
  
  
  __SCREAMING_SNAKE_CASE					=						logging.get_logger(__name__)
  
  __SCREAMING_SNAKE_CASE					=						{
      """bert-base-uncased""": """https://huggingface.co/bert-base-uncased/resolve/main/config.json""",
      # QDQBERT models can be loaded from any BERT checkpoint, available at https://huggingface.co/models?filter=bert
  }
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     lowerCAmelCase_				:   Tuple     	=			'qdqbert'
  
  
  
  
     def __init__(		self							:List[Any]				,  UpperCamelCase__							:List[Any]=30_522				,  UpperCamelCase__							:Optional[int]=768				,  UpperCamelCase__							:str=12				,  UpperCamelCase__							:Tuple=12				,  UpperCamelCase__							:Any=3_072				,  UpperCamelCase__							:Union[str, Any]="gelu"				,  UpperCamelCase__							:Dict=0.1				,  UpperCamelCase__							:Any=0.1				,  UpperCamelCase__							:Dict=512				,  UpperCamelCase__							:Optional[int]=2				,  UpperCamelCase__							:Any=0.02				,  UpperCamelCase__							:Optional[int]=1E-12				,  UpperCamelCase__							:str=True				,  UpperCamelCase__							:str=1				,  UpperCamelCase__							:List[Any]=0				,  UpperCamelCase__							:List[str]=2				,  **UpperCamelCase__							:Optional[Any]				,  ):
            super().__init__(pad_token_id=UpperCamelCase__				,  bos_token_id=UpperCamelCase__				,  eos_token_id=UpperCamelCase__				,  **UpperCamelCase__       )
  
            _a          =				vocab_size
            _a          =				max_position_embeddings
            _a          =				hidden_size
            _a          =				num_hidden_layers
            _a          =				num_attention_heads
            _a          =				intermediate_size
            _a          =				hidden_act
            _a          =				hidden_dropout_prob
            _a          =				attention_probs_dropout_prob
            _a          =				initializer_range
            _a          =				type_vocab_size
            _a          =				layer_norm_eps
            _a          =				use_cache
  