
'''simple docstring'''





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

from ... import PreTrainedTokenizer, TensorType, is_torch_available
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast, PatchingSpec
from ...utils import logging


SCREAMING_SNAKE_CASE     =       logging.get_logger(__name__)

SCREAMING_SNAKE_CASE     =       {
    """EleutherAI/gpt-j-6B""": """https://huggingface.co/EleutherAI/gpt-j-6B/resolve/main/config.json""",
    # See all GPT-J models at https://huggingface.co/models?filter=gpt_j
}






class 							UpperCAmelCase_							(    _a				):

 '''simple docstring'''
 lowercase_					:    Tuple				=							"gptj"
 lowercase_					:    Optional[Any]				=							{
     "max_position_embeddings": "n_positions",
     "hidden_size": "n_embd",
     "num_attention_heads": "n_head",
     "num_hidden_layers": "n_layer",
 }







 def __init__(					self		:  Union[str, Any]			,				snake_case__		:  Optional[int]=5_04_00			,				snake_case__		:  Optional[int]=20_48			,				snake_case__		:  Union[str, Any]=40_96			,				snake_case__		:  List[Any]=28			,				snake_case__		:  List[Any]=16			,				snake_case__		:  Optional[Any]=64			,				snake_case__		:  Optional[int]=None			,				snake_case__		:  Dict="gelu_new"			,				snake_case__		:  Optional[Any]=0.0			,				snake_case__		:  Union[str, Any]=0.0			,				snake_case__		:  Union[str, Any]=0.0			,				snake_case__		:  Union[str, Any]=1e-5			,				snake_case__		:  Tuple=0.02			,				snake_case__		:  Any=True			,				snake_case__		:  List[Any]=5_02_56			,				snake_case__		:  int=5_02_56			,				snake_case__		:  Any=False			,				**snake_case__		:  Tuple			,				):



   '''simple docstring'''




   UpperCAmelCase__      :					List[str]				       =							vocab_size
   UpperCAmelCase__      :					str				       =							n_positions
   UpperCAmelCase__      :					Dict				       =							n_embd
   UpperCAmelCase__      :					Tuple				       =							n_layer
   UpperCAmelCase__      :					Any				       =							n_head
   UpperCAmelCase__      :					Dict				       =							n_inner
   UpperCAmelCase__      :					Dict				       =							rotary_dim
   UpperCAmelCase__      :					Any				       =							activation_function
   UpperCAmelCase__      :					List[Any]				       =							resid_pdrop
   UpperCAmelCase__      :					Tuple				       =							embd_pdrop
   UpperCAmelCase__      :					Optional[Any]				       =							attn_pdrop
   UpperCAmelCase__      :					Optional[int]				       =							layer_norm_epsilon
   UpperCAmelCase__      :					int				       =							initializer_range
   UpperCAmelCase__      :					Dict				       =							use_cache

   UpperCAmelCase__      :					Dict				       =							bos_token_id
   UpperCAmelCase__      :					Union[str, Any]				       =							eos_token_id

   super().__init__(
       bos_token_id=_SCREAMING_SNAKE_CASE			,				eos_token_id=_SCREAMING_SNAKE_CASE			,				tie_word_embeddings=_SCREAMING_SNAKE_CASE			,				**_SCREAMING_SNAKE_CASE )






class 							UpperCAmelCase_							(    _a				):

 '''simple docstring'''







 def __init__(					self		:  List[Any]			,				snake_case__		:  Optional[int]			,				snake_case__		:  Tuple = "default"			,				snake_case__		:  int = None			,				snake_case__		:  List[Any] = False			,				):



   '''simple docstring'''




   super().__init__(_SCREAMING_SNAKE_CASE			,				task=_SCREAMING_SNAKE_CASE			,				patching_specs=_SCREAMING_SNAKE_CASE			,				use_past=_SCREAMING_SNAKE_CASE )
   if not getattr(self._config			,				"pad_token_id"			,				_SCREAMING_SNAKE_CASE ):
     # TODO: how to do that better?
     UpperCAmelCase__      :					Any				       =							0







 @property
 def 							UpperCamelCase  (					self		:  List[str] ):



   '''simple docstring'''




   UpperCAmelCase__      :					Optional[Any]				       =							OrderedDict({"input_ids": {0: "batch", 1: "sequence"}} )
   if self.use_past:
     self.fill_with_past_key_values_(_SCREAMING_SNAKE_CASE			,				direction="inputs" )
     UpperCAmelCase__      :					List[Any]				       =							{0: '''batch''', 1: '''past_sequence + sequence'''}
   else:
     UpperCAmelCase__      :					int				       =							{0: '''batch''', 1: '''sequence'''}

   return common_inputs







 @property
 def 							UpperCamelCase  (					self		:  Any ):



   '''simple docstring'''




   return self._config.n_layer







 @property
 def 							UpperCamelCase  (					self		:  str ):



   '''simple docstring'''




   return self._config.n_head







 def 							UpperCamelCase  (					self		:  Tuple			,				snake_case__		:  Tuple			,				snake_case__		:  Dict = -1			,				snake_case__		:  int = -1			,				snake_case__		:  Union[str, Any] = False			,				snake_case__		:  str = None			,				):



   '''simple docstring'''




   UpperCAmelCase__      :					Any				       =							super(_SCREAMING_SNAKE_CASE			,				self ).generate_dummy_inputs(
       _SCREAMING_SNAKE_CASE			,				batch_size=_SCREAMING_SNAKE_CASE			,				seq_length=_SCREAMING_SNAKE_CASE			,				is_pair=_SCREAMING_SNAKE_CASE			,				framework=_SCREAMING_SNAKE_CASE )

   # We need to order the input in the way they appears in the forward()
   UpperCAmelCase__      :					Union[str, Any]				       =							OrderedDict({"input_ids": common_inputs["input_ids"]} )

   # Need to add the past_keys
   if self.use_past:
     if not is_torch_available():
       raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed." )
     else:
       import torch

       UpperCAmelCase__      :					Any				       =							common_inputs['''input_ids'''].shape
       # Not using the same length for past_key_values
       UpperCAmelCase__      :					int				       =							seqlen + 2
       UpperCAmelCase__      :					Optional[Any]				       =							(
           batch,
           self.num_attention_heads,
           past_key_values_length,
           self._config.hidden_size // self.num_attention_heads,
       )
       UpperCAmelCase__      :					Optional[Any]				       =							[
           (torch.zeros(_SCREAMING_SNAKE_CASE ), torch.zeros(_SCREAMING_SNAKE_CASE )) for _ in range(self.num_layers )
       ]

   UpperCAmelCase__      :					List[Any]				       =							common_inputs['''attention_mask''']
   if self.use_past:
     UpperCAmelCase__      :					List[str]				       =							ordered_inputs['''attention_mask'''].dtype
     UpperCAmelCase__      :					Tuple				       =							torch.cat(
         [ordered_inputs["attention_mask"], torch.ones(_SCREAMING_SNAKE_CASE			,				_SCREAMING_SNAKE_CASE			,				dtype=_SCREAMING_SNAKE_CASE )]			,				dim=1 )

   return ordered_inputs







 @property
 def 							UpperCamelCase  (					self		:  Dict ):



   '''simple docstring'''




   return 13









import functools
import operator

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__a							     =					logging.get_logger(__name__)

__a							     =					{
    'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json',
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}

class     __a(	_a  ):






    """simple docstring"""





    lowerCAmelCase         = '''wav2vec2'''





    def __init__( self  ,_SCREAMING_SNAKE_CASE=32  ,_SCREAMING_SNAKE_CASE=768  ,_SCREAMING_SNAKE_CASE=12  ,_SCREAMING_SNAKE_CASE=12  ,_SCREAMING_SNAKE_CASE=3_072  ,_SCREAMING_SNAKE_CASE="gelu"  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.0  ,_SCREAMING_SNAKE_CASE=0.0  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=0.02  ,_SCREAMING_SNAKE_CASE=1e-5  ,_SCREAMING_SNAKE_CASE="group"  ,_SCREAMING_SNAKE_CASE="gelu"  ,_SCREAMING_SNAKE_CASE=(512, 512, 512, 512, 512, 512, 512)  ,_SCREAMING_SNAKE_CASE=(5, 2, 2, 2, 2, 2, 2)  ,_SCREAMING_SNAKE_CASE=(10, 3, 3, 3, 3, 2, 2)  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=128  ,_SCREAMING_SNAKE_CASE=16  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=True  ,_SCREAMING_SNAKE_CASE=0.05  ,_SCREAMING_SNAKE_CASE=10  ,_SCREAMING_SNAKE_CASE=2  ,_SCREAMING_SNAKE_CASE=0.0  ,_SCREAMING_SNAKE_CASE=10  ,_SCREAMING_SNAKE_CASE=0  ,_SCREAMING_SNAKE_CASE=320  ,_SCREAMING_SNAKE_CASE=2  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE=100  ,_SCREAMING_SNAKE_CASE=256  ,_SCREAMING_SNAKE_CASE=256  ,_SCREAMING_SNAKE_CASE=0.1  ,_SCREAMING_SNAKE_CASE="sum"  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=256  ,_SCREAMING_SNAKE_CASE=(512, 512, 512, 512, 1_500)  ,_SCREAMING_SNAKE_CASE=(5, 3, 3, 1, 1)  ,_SCREAMING_SNAKE_CASE=(1, 2, 3, 1, 1)  ,_SCREAMING_SNAKE_CASE=512  ,_SCREAMING_SNAKE_CASE=0  ,_SCREAMING_SNAKE_CASE=1  ,_SCREAMING_SNAKE_CASE=2  ,_SCREAMING_SNAKE_CASE=False  ,_SCREAMING_SNAKE_CASE=3  ,_SCREAMING_SNAKE_CASE=2  ,_SCREAMING_SNAKE_CASE=3  ,_SCREAMING_SNAKE_CASE=None  ,_SCREAMING_SNAKE_CASE=None  ,**_SCREAMING_SNAKE_CASE  ,)					->						Optional[int]:
         super().__init__(**_SCREAMING_SNAKE_CASE  ,pad_token_id=_SCREAMING_SNAKE_CASE  ,bos_token_id=_SCREAMING_SNAKE_CASE  ,eos_token_id=_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				int  =     hidden_size
         UpperCAmelCase_     :				Tuple  =     feat_extract_norm
         UpperCAmelCase_     :				List[Any]  =     feat_extract_activation
         UpperCAmelCase_     :				str  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Any  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Tuple  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Dict  =     conv_bias
         UpperCAmelCase_     :				str  =     num_conv_pos_embeddings
         UpperCAmelCase_     :				Any  =     num_conv_pos_embedding_groups
         UpperCAmelCase_     :				Tuple  =     len(self.conv_dim    )
         UpperCAmelCase_     :				Union[str, Any]  =     num_hidden_layers
         UpperCAmelCase_     :				Dict  =     intermediate_size
         UpperCAmelCase_     :				Any  =     hidden_act
         UpperCAmelCase_     :				Any  =     num_attention_heads
         UpperCAmelCase_     :				str  =     hidden_dropout
         UpperCAmelCase_     :				int  =     attention_dropout
         UpperCAmelCase_     :				Tuple  =     activation_dropout
         UpperCAmelCase_     :				List[str]  =     feat_proj_dropout
         UpperCAmelCase_     :				int  =     final_dropout
         UpperCAmelCase_     :				Union[str, Any]  =     layerdrop
         UpperCAmelCase_     :				Optional[Any]  =     layer_norm_eps
         UpperCAmelCase_     :				str  =     initializer_range
         UpperCAmelCase_     :				List[str]  =     vocab_size
         UpperCAmelCase_     :				Optional[int]  =     do_stable_layer_norm
         UpperCAmelCase_     :				Optional[int]  =     use_weighted_layer_sum

         if (
             (len(self.conv_stride    ) != self.num_feat_extract_layers)
             or (len(self.conv_kernel    ) != self.num_feat_extract_layers)
             or (len(self.conv_dim    ) != self.num_feat_extract_layers)
         ):
              raise ValueError(
                  '''Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =='''
                  ''' `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ='''
                  f''' {len(self.conv_dim    )}`, `len(config.conv_stride) = {len(self.conv_stride    )}`,'''
                  f''' `len(config.conv_kernel) = {len(self.conv_kernel    )}`.'''    )

         # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
         UpperCAmelCase_     :				Optional[int]  =     apply_spec_augment
         UpperCAmelCase_     :				Tuple  =     mask_time_prob
         UpperCAmelCase_     :				Optional[Any]  =     mask_time_length
         UpperCAmelCase_     :				Union[str, Any]  =     mask_time_min_masks
         UpperCAmelCase_     :				Optional[Any]  =     mask_feature_prob
         UpperCAmelCase_     :				str  =     mask_feature_length
         UpperCAmelCase_     :				Dict  =     mask_feature_min_masks

         # parameters for pretraining with codevector quantized representations
         UpperCAmelCase_     :				Union[str, Any]  =     num_codevectors_per_group
         UpperCAmelCase_     :				Any  =     num_codevector_groups
         UpperCAmelCase_     :				Union[str, Any]  =     contrastive_logits_temperature
         UpperCAmelCase_     :				List[str]  =     feat_quantizer_dropout
         UpperCAmelCase_     :				Dict  =     num_negatives
         UpperCAmelCase_     :				List[str]  =     codevector_dim
         UpperCAmelCase_     :				List[str]  =     proj_codevector_dim
         UpperCAmelCase_     :				str  =     diversity_loss_weight

         # ctc loss
         UpperCAmelCase_     :				List[Any]  =     ctc_loss_reduction
         UpperCAmelCase_     :				List[str]  =     ctc_zero_infinity

         # adapter
         UpperCAmelCase_     :				Optional[Any]  =     add_adapter
         UpperCAmelCase_     :				Any  =     adapter_kernel_size
         UpperCAmelCase_     :				Optional[int]  =     adapter_stride
         UpperCAmelCase_     :				List[Any]  =     num_adapter_layers
         UpperCAmelCase_     :				Optional[Any]  =     output_hidden_size or hidden_size
         UpperCAmelCase_     :				Optional[int]  =     adapter_attn_dim

         # SequenceClassification-specific parameter. Feel free to ignore for other classes.
         UpperCAmelCase_     :				List[str]  =     classifier_proj_size

         # XVector-specific parameters. Feel free to ignore for other classes.
         UpperCAmelCase_     :				List[str]  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				int  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Dict  =     list(_SCREAMING_SNAKE_CASE    )
         UpperCAmelCase_     :				Any  =     xvector_output_dim





    @property
    def 				a__ ( self    )					->						Any:
         return functools.reduce(operator.mul  ,self.conv_stride  ,1    )