



"""simple docstring"""






import functools
import operator

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


lowerCAmelCase__              =							logging.get_logger(__name__)

lowerCAmelCase__              =							{
    '''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 			__snake_case			(      _lowercase):
  snake_case__							:  Any         =		"wav2vec2"




  def __init__(					self	:		Any		,   __lowerCAmelCase	:		Optional[Any]=3_2		,   __lowerCAmelCase	:		List[Any]=7_6_8		,   __lowerCAmelCase	:		Dict=1_2		,   __lowerCAmelCase	:		Tuple=1_2		,   __lowerCAmelCase	:		Optional[int]=3_0_7_2		,   __lowerCAmelCase	:		Any="gelu"		,   __lowerCAmelCase	:		List[str]=0.1		,   __lowerCAmelCase	:		Dict=0.1		,   __lowerCAmelCase	:		Union[str, Any]=0.1		,   __lowerCAmelCase	:		Dict=0.0		,   __lowerCAmelCase	:		Optional[int]=0.0		,   __lowerCAmelCase	:		List[Any]=0.1		,   __lowerCAmelCase	:		List[Any]=0.1		,   __lowerCAmelCase	:		Dict=0.02		,   __lowerCAmelCase	:		Any=1E-5		,   __lowerCAmelCase	:		Any="group"		,   __lowerCAmelCase	:		Union[str, Any]="gelu"		,   __lowerCAmelCase	:		str=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)		,   __lowerCAmelCase	:		Optional[Any]=(5, 2, 2, 2, 2, 2, 2)		,   __lowerCAmelCase	:		Optional[Any]=(1_0, 3, 3, 3, 3, 2, 2)		,   __lowerCAmelCase	:		int=False		,   __lowerCAmelCase	:		int=1_2_8		,   __lowerCAmelCase	:		Union[str, Any]=1_6		,   __lowerCAmelCase	:		Union[str, Any]=False		,   __lowerCAmelCase	:		List[Any]=True		,   __lowerCAmelCase	:		Dict=0.05		,   __lowerCAmelCase	:		List[str]=1_0		,   __lowerCAmelCase	:		Tuple=2		,   __lowerCAmelCase	:		str=0.0		,   __lowerCAmelCase	:		Union[str, Any]=1_0		,   __lowerCAmelCase	:		int=0		,   __lowerCAmelCase	:		Optional[int]=3_2_0		,   __lowerCAmelCase	:		Optional[Any]=2		,   __lowerCAmelCase	:		str=0.1		,   __lowerCAmelCase	:		Optional[Any]=1_0_0		,   __lowerCAmelCase	:		Tuple=2_5_6		,   __lowerCAmelCase	:		Union[str, Any]=2_5_6		,   __lowerCAmelCase	:		Union[str, Any]=0.1		,   __lowerCAmelCase	:		Optional[Any]="sum"		,   __lowerCAmelCase	:		List[str]=False		,   __lowerCAmelCase	:		List[Any]=False		,   __lowerCAmelCase	:		List[str]=2_5_6		,   __lowerCAmelCase	:		List[Any]=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 1_5_0_0)		,   __lowerCAmelCase	:		List[str]=(5, 3, 3, 1, 1)		,   __lowerCAmelCase	:		Union[str, Any]=(1, 2, 3, 1, 1)		,   __lowerCAmelCase	:		Optional[Any]=5_1_2		,   __lowerCAmelCase	:		Any=0		,   __lowerCAmelCase	:		Optional[int]=1		,   __lowerCAmelCase	:		List[str]=2		,   __lowerCAmelCase	:		Tuple=False		,   __lowerCAmelCase	:		Any=3		,   __lowerCAmelCase	:		List[Any]=2		,   __lowerCAmelCase	:		Optional[Any]=3		,   __lowerCAmelCase	:		List[str]=None		,   __lowerCAmelCase	:		str=None		,   **__lowerCAmelCase	:		Tuple		,   ):






         """simple docstring"""






         super().__init__(**_lowerCAmelCase		,   pad_token_id=_lowerCAmelCase		,   bos_token_id=_lowerCAmelCase		,   eos_token_id=_lowerCAmelCase						)
         _lowerCamelCase		:							str            =					hidden_size
         _lowerCamelCase		:							List[Any]            =					feat_extract_norm
         _lowerCamelCase		:							Optional[int]            =					feat_extract_activation
         _lowerCamelCase		:							Dict            =					list(_lowerCAmelCase						)
         _lowerCamelCase		:							Optional[Any]            =					list(_lowerCAmelCase						)
         _lowerCamelCase		:							str            =					list(_lowerCAmelCase						)
         _lowerCamelCase		:							Union[str, Any]            =					conv_bias
         _lowerCamelCase		:							Union[str, Any]            =					num_conv_pos_embeddings
         _lowerCamelCase		:							Optional[int]            =					num_conv_pos_embedding_groups
         _lowerCamelCase		:							int            =					len(self.conv_dim						)
         _lowerCamelCase		:							int            =					num_hidden_layers
         _lowerCamelCase		:							Union[str, Any]            =					intermediate_size
         _lowerCamelCase		:							Tuple            =					hidden_act
         _lowerCamelCase		:							Union[str, Any]            =					num_attention_heads
         _lowerCamelCase		:							List[Any]            =					hidden_dropout
         _lowerCamelCase		:							Dict            =					attention_dropout
         _lowerCamelCase		:							Any            =					activation_dropout
         _lowerCamelCase		:							str            =					feat_proj_dropout
         _lowerCamelCase		:							List[Any]            =					final_dropout
         _lowerCamelCase		:							Any            =					layerdrop
         _lowerCamelCase		:							Union[str, Any]            =					layer_norm_eps
         _lowerCamelCase		:							List[str]            =					initializer_range
         _lowerCamelCase		:							List[Any]            =					vocab_size
         _lowerCamelCase		:							str            =					do_stable_layer_norm
         _lowerCamelCase		:							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
         _lowerCamelCase		:							Union[str, Any]            =					apply_spec_augment
         _lowerCamelCase		:							List[str]            =					mask_time_prob
         _lowerCamelCase		:							Tuple            =					mask_time_length
         _lowerCamelCase		:							List[Any]            =					mask_time_min_masks
         _lowerCamelCase		:							str            =					mask_feature_prob
         _lowerCamelCase		:							Optional[int]            =					mask_feature_length
         _lowerCamelCase		:							List[str]            =					mask_feature_min_masks

         # parameters for pretraining with codevector quantized representations
         _lowerCamelCase		:							Any            =					num_codevectors_per_group
         _lowerCamelCase		:							Optional[Any]            =					num_codevector_groups
         _lowerCamelCase		:							Optional[Any]            =					contrastive_logits_temperature
         _lowerCamelCase		:							str            =					feat_quantizer_dropout
         _lowerCamelCase		:							int            =					num_negatives
         _lowerCamelCase		:							Tuple            =					codevector_dim
         _lowerCamelCase		:							Optional[int]            =					proj_codevector_dim
         _lowerCamelCase		:							Tuple            =					diversity_loss_weight

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

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

         # SequenceClassification-specific parameter. Feel free to ignore for other classes.
         _lowerCamelCase		:							Tuple            =					classifier_proj_size

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




  @property
  def 		SCREAMING_SNAKE_CASE							(					self	:		str						):






         """simple docstring"""






         return functools.reduce(operator.mul		,   self.conv_stride		,   1						)






import importlib.metadata
from typing import Union

from packaging.version import Version, parse

from .constants import STR_OPERATION_TO_FUNC


SCREAMING_SNAKE_CASE						:Union[str, Any]			=  parse(importlib.metadata.version('''torch'''))



def       _lowerCAmelCase    (				lowerCAmelCase_				:Union[str, Version]		,    lowerCAmelCase_				:str		,    lowerCAmelCase_				:str				)->Any:
   '''simple docstring'''






   if operation not in STR_OPERATION_TO_FUNC.keys():
      raise ValueError(F'''`operation` must be one of {list(STR_OPERATION_TO_FUNC.keys()				)}, received {operation}'''				)
   snake_case_            =       STR_OPERATION_TO_FUNC[operation]
   if isinstance(lowerCAmelCase_		,    lowerCAmelCase_				):
      snake_case_            =       parse(importlib.metadata.version(lowerCAmelCase_				)				)
   return operation(lowerCAmelCase_		,    parse(lowerCAmelCase_				)				)



def       _lowerCAmelCase    (				lowerCAmelCase_				:str		,    lowerCAmelCase_				:str				)->Any:
   '''simple docstring'''






   return compare_versions(lowerCAmelCase_		,    lowerCAmelCase_		,    lowerCAmelCase_				)




