





'''simple docstring'''




import functools
import operator

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


_SCREAMING_SNAKE_CASE							     =			logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE							     =			{
    "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 			_lowerCAmelCase		(			A__	):






     """simple docstring"""






     snake_case_						      =   "wav2vec2"



     def __init__(   self							:			str   ,       __snake_case							:			Union[str, Any]=32   ,       __snake_case							:			str=7_68   ,       __snake_case							:			Tuple=12   ,       __snake_case							:			Tuple=12   ,       __snake_case							:			str=30_72   ,       __snake_case							:			Union[str, Any]="gelu"   ,       __snake_case							:			int=0.1   ,       __snake_case							:			Any=0.1   ,       __snake_case							:			List[Any]=0.1   ,       __snake_case							:			Union[str, Any]=0.0   ,       __snake_case							:			int=0.0   ,       __snake_case							:			int=0.1   ,       __snake_case							:			Union[str, Any]=0.1   ,       __snake_case							:			str=0.02   ,       __snake_case							:			Union[str, Any]=1e-5   ,       __snake_case							:			Tuple="group"   ,       __snake_case							:			Union[str, Any]="gelu"   ,       __snake_case							:			List[Any]=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)   ,       __snake_case							:			Optional[Any]=(5, 2, 2, 2, 2, 2, 2)   ,       __snake_case							:			int=(10, 3, 3, 3, 3, 2, 2)   ,       __snake_case							:			List[Any]=False   ,       __snake_case							:			Optional[Any]=1_28   ,       __snake_case							:			str=16   ,       __snake_case							:			Optional[int]=False   ,       __snake_case							:			Dict=True   ,       __snake_case							:			List[str]=0.05   ,       __snake_case							:			Any=10   ,       __snake_case							:			Optional[Any]=2   ,       __snake_case							:			List[str]=0.0   ,       __snake_case							:			Union[str, Any]=10   ,       __snake_case							:			Union[str, Any]=0   ,       __snake_case							:			List[Any]=3_20   ,       __snake_case							:			str=2   ,       __snake_case							:			Dict=0.1   ,       __snake_case							:			Any=1_00   ,       __snake_case							:			Optional[int]=2_56   ,       __snake_case							:			List[Any]=2_56   ,       __snake_case							:			Union[str, Any]=0.1   ,       __snake_case							:			List[Any]="sum"   ,       __snake_case							:			Any=False   ,       __snake_case							:			str=False   ,       __snake_case							:			Dict=2_56   ,       __snake_case							:			Union[str, Any]=(5_12, 5_12, 5_12, 5_12, 15_00)   ,       __snake_case							:			Optional[int]=(5, 3, 3, 1, 1)   ,       __snake_case							:			int=(1, 2, 3, 1, 1)   ,       __snake_case							:			Tuple=5_12   ,       __snake_case							:			str=0   ,       __snake_case							:			str=1   ,       __snake_case							:			List[str]=2   ,       __snake_case							:			Optional[Any]=False   ,       __snake_case							:			int=3   ,       __snake_case							:			int=2   ,       __snake_case							:			List[Any]=3   ,       __snake_case							:			Tuple=None   ,       __snake_case							:			Dict=None   ,       **__snake_case							:			List[Any]   ,       )->	Tuple:
        super().__init__(**__snake_case   ,       pad_token_id=__snake_case   ,       bos_token_id=__snake_case   ,       eos_token_id=__snake_case						)
        snake_case 						=   hidden_size
        snake_case 						=   feat_extract_norm
        snake_case 						=   feat_extract_activation
        snake_case 						=   list(__snake_case						)
        snake_case 						=   list(__snake_case						)
        snake_case 						=   list(__snake_case						)
        snake_case 						=   conv_bias
        snake_case 						=   num_conv_pos_embeddings
        snake_case 						=   num_conv_pos_embedding_groups
        snake_case 						=   len(self.conv_dim						)
        snake_case 						=   num_hidden_layers
        snake_case 						=   intermediate_size
        snake_case 						=   hidden_act
        snake_case 						=   num_attention_heads
        snake_case 						=   hidden_dropout
        snake_case 						=   attention_dropout
        snake_case 						=   activation_dropout
        snake_case 						=   feat_proj_dropout
        snake_case 						=   final_dropout
        snake_case 						=   layerdrop
        snake_case 						=   layer_norm_eps
        snake_case 						=   initializer_range
        snake_case 						=   vocab_size
        snake_case 						=   do_stable_layer_norm
        snake_case 						=   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
        snake_case 						=   apply_spec_augment
        snake_case 						=   mask_time_prob
        snake_case 						=   mask_time_length
        snake_case 						=   mask_time_min_masks
        snake_case 						=   mask_feature_prob
        snake_case 						=   mask_feature_length
        snake_case 						=   mask_feature_min_masks

        # parameters for pretraining with codevector quantized representations
        snake_case 						=   num_codevectors_per_group
        snake_case 						=   num_codevector_groups
        snake_case 						=   contrastive_logits_temperature
        snake_case 						=   feat_quantizer_dropout
        snake_case 						=   num_negatives
        snake_case 						=   codevector_dim
        snake_case 						=   proj_codevector_dim
        snake_case 						=   diversity_loss_weight

        # ctc loss
        snake_case 						=   ctc_loss_reduction
        snake_case 						=   ctc_zero_infinity

        # adapter
        snake_case 						=   add_adapter
        snake_case 						=   adapter_kernel_size
        snake_case 						=   adapter_stride
        snake_case 						=   num_adapter_layers
        snake_case 						=   output_hidden_size or hidden_size
        snake_case 						=   adapter_attn_dim

        # SequenceClassification-specific parameter. Feel free to ignore for other classes.
        snake_case 						=   classifier_proj_size

        # XVector-specific parameters. Feel free to ignore for other classes.
        snake_case 						=   list(__snake_case						)
        snake_case 						=   list(__snake_case						)
        snake_case 						=   list(__snake_case						)
        snake_case 						=   xvector_output_dim



     @property
     def      lowerCAmelCase			(   self							:			Optional[int]						)->	List[Any]:
        return functools.reduce(operator.mul   ,       self.conv_stride   ,       1						)








'''simple docstring'''




import logging

from transformers.configuration_utils import PretrainedConfig


_SCREAMING_SNAKE_CASE							     =			logging.getLogger(__name__)
class 			_lowerCAmelCase		(			A__	):






     """simple docstring"""






     snake_case_						      =   "masked_bert"



     def __init__(   self							:			Any   ,       __snake_case							:			Optional[Any]=3_05_22   ,       __snake_case							:			List[Any]=7_68   ,       __snake_case							:			int=12   ,       __snake_case							:			List[str]=12   ,       __snake_case							:			int=30_72   ,       __snake_case							:			Optional[int]="gelu"   ,       __snake_case							:			Any=0.1   ,       __snake_case							:			Tuple=0.1   ,       __snake_case							:			List[str]=5_12   ,       __snake_case							:			Tuple=2   ,       __snake_case							:			Tuple=0.02   ,       __snake_case							:			Tuple=1e-12   ,       __snake_case							:			Union[str, Any]=0   ,       __snake_case							:			int="topK"   ,       __snake_case							:			int="constant"   ,       __snake_case							:			List[str]=0.0   ,       **__snake_case							:			Any   ,       )->	Union[str, Any]:
        super().__init__(pad_token_id=__snake_case   ,       **__snake_case						)

        snake_case 						=   vocab_size
        snake_case 						=   hidden_size
        snake_case 						=   num_hidden_layers
        snake_case 						=   num_attention_heads
        snake_case 						=   hidden_act
        snake_case 						=   intermediate_size
        snake_case 						=   hidden_dropout_prob
        snake_case 						=   attention_probs_dropout_prob
        snake_case 						=   max_position_embeddings
        snake_case 						=   type_vocab_size
        snake_case 						=   initializer_range
        snake_case 						=   layer_norm_eps
        snake_case 						=   pruning_method
        snake_case 						=   mask_init
        snake_case 						=   mask_scale

