import functools
import operator

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


__lowercase							 =					logging.get_logger(__name__)

__lowercase							 =					{
    '''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_     (   UpperCAmelCase_ ):






    '''simple docstring'''






    a__	:						Union[str, Any]						=      """wav2vec2"""







    def __init__(	self , __lowercase=32 , __lowercase=768 , __lowercase=12 , __lowercase=12 , __lowercase=3_072 , __lowercase="gelu" , __lowercase=0.1 , __lowercase=0.1 , __lowercase=0.1 , __lowercase=0.0 , __lowercase=0.0 , __lowercase=0.1 , __lowercase=0.1 , __lowercase=0.02 , __lowercase=1E-5 , __lowercase="group" , __lowercase="gelu" , __lowercase=(512, 512, 512, 512, 512, 512, 512) , __lowercase=(5, 2, 2, 2, 2, 2, 2) , __lowercase=(10, 3, 3, 3, 3, 2, 2) , __lowercase=False , __lowercase=128 , __lowercase=16 , __lowercase=False , __lowercase=True , __lowercase=0.05 , __lowercase=10 , __lowercase=2 , __lowercase=0.0 , __lowercase=10 , __lowercase=0 , __lowercase=320 , __lowercase=2 , __lowercase=0.1 , __lowercase=100 , __lowercase=256 , __lowercase=256 , __lowercase=0.1 , __lowercase="sum" , __lowercase=False , __lowercase=False , __lowercase=256 , __lowercase=(512, 512, 512, 512, 1_500) , __lowercase=(5, 3, 3, 1, 1) , __lowercase=(1, 2, 3, 1, 1) , __lowercase=512 , __lowercase=0 , __lowercase=1 , __lowercase=2 , __lowercase=False , __lowercase=3 , __lowercase=2 , __lowercase=3 , __lowercase=None , __lowercase=None , **__lowercase , )       ->	int:
        super().__init__(**__lowercase , pad_token_id=__lowercase , bos_token_id=__lowercase , eos_token_id=__lowercase)
        __UpperCamelCase     :Any			  =		hidden_size
        __UpperCamelCase     :int			  =		feat_extract_norm
        __UpperCamelCase     :Tuple			  =		feat_extract_activation
        __UpperCamelCase     :Union[str, Any]			  =		list(__lowercase)
        __UpperCamelCase     :List[Any]			  =		list(__lowercase)
        __UpperCamelCase     :int			  =		list(__lowercase)
        __UpperCamelCase     :List[Any]			  =		conv_bias
        __UpperCamelCase     :Optional[int]			  =		num_conv_pos_embeddings
        __UpperCamelCase     :Dict			  =		num_conv_pos_embedding_groups
        __UpperCamelCase     :Any			  =		len(self.conv_dim)
        __UpperCamelCase     :List[str]			  =		num_hidden_layers
        __UpperCamelCase     :int			  =		intermediate_size
        __UpperCamelCase     :str			  =		hidden_act
        __UpperCamelCase     :Any			  =		num_attention_heads
        __UpperCamelCase     :int			  =		hidden_dropout
        __UpperCamelCase     :Tuple			  =		attention_dropout
        __UpperCamelCase     :List[str]			  =		activation_dropout
        __UpperCamelCase     :Optional[Any]			  =		feat_proj_dropout
        __UpperCamelCase     :Any			  =		final_dropout
        __UpperCamelCase     :Any			  =		layerdrop
        __UpperCamelCase     :str			  =		layer_norm_eps
        __UpperCamelCase     :Optional[Any]			  =		initializer_range
        __UpperCamelCase     :List[str]			  =		vocab_size
        __UpperCamelCase     :str			  =		do_stable_layer_norm
        __UpperCamelCase     :Union[str, Any]			  =		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     :List[Any]			  =		apply_spec_augment
        __UpperCamelCase     :Tuple			  =		mask_time_prob
        __UpperCamelCase     :int			  =		mask_time_length
        __UpperCamelCase     :Dict			  =		mask_time_min_masks
        __UpperCamelCase     :str			  =		mask_feature_prob
        __UpperCamelCase     :List[str]			  =		mask_feature_length
        __UpperCamelCase     :Union[str, Any]			  =		mask_feature_min_masks

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

        # ctc loss
        __UpperCamelCase     :Tuple			  =		ctc_loss_reduction
        __UpperCamelCase     :Tuple			  =		ctc_zero_infinity

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

        # SequenceClassification-specific parameter. Feel free to ignore for other classes.
        __UpperCamelCase     :Optional[Any]			  =		classifier_proj_size

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







    @property
    def 			UpperCamelCase__   (	self)       ->	List[str]:
        return functools.reduce(operator.mul , self.conv_stride , 1)










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


__UpperCAmelCase          =       logging.get_logger(__name__)

__UpperCAmelCase          =       {
    '''facebook/s2t-wav2vec2-large-en-de''': (
        '''https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json'''
    ),
    # See all Speech2Text models at https://huggingface.co/models?filter=speech2text2
}



class 				lowerCAmelCase_		(  a__							):
       UpperCAmelCase__				:					Optional[Any]        =  "speech_to_text_2"
       UpperCAmelCase__				:					List[Any]        =  ["past_key_values"]
       UpperCAmelCase__				:					Any        =  {"num_attention_heads": "decoder_attention_heads", "hidden_size": "d_model"}
       def __init__(			self,			SCREAMING_SNAKE_CASE_=1_0000,			SCREAMING_SNAKE_CASE_=6,			SCREAMING_SNAKE_CASE_=2048,			SCREAMING_SNAKE_CASE_=4,			SCREAMING_SNAKE_CASE_=0.0,			SCREAMING_SNAKE_CASE_=True,			SCREAMING_SNAKE_CASE_="relu",			SCREAMING_SNAKE_CASE_=256,			SCREAMING_SNAKE_CASE_=0.1,			SCREAMING_SNAKE_CASE_=0.0,			SCREAMING_SNAKE_CASE_=0.0,			SCREAMING_SNAKE_CASE_=0.02,			SCREAMING_SNAKE_CASE_=2,			SCREAMING_SNAKE_CASE_=True,			SCREAMING_SNAKE_CASE_=1,			SCREAMING_SNAKE_CASE_=0,			SCREAMING_SNAKE_CASE_=2,			SCREAMING_SNAKE_CASE_=1024,			**SCREAMING_SNAKE_CASE_,			)     ->		int:
          UpperCamelCase    :  Optional[int]							=	vocab_size
          UpperCamelCase    :  List[str]							=	d_model
          UpperCamelCase    :  List[str]							=	decoder_ffn_dim
          UpperCamelCase    :  Optional[Any]							=	decoder_layers
          UpperCamelCase    :  Any							=	decoder_attention_heads
          UpperCamelCase    :  Tuple							=	dropout
          UpperCamelCase    :  str							=	attention_dropout
          UpperCamelCase    :  str							=	activation_dropout
          UpperCamelCase    :  Union[str, Any]							=	activation_function
          UpperCamelCase    :  Optional[int]							=	init_std
          UpperCamelCase    :  Tuple							=	decoder_layerdrop
          UpperCamelCase    :  Dict							=	use_cache
          UpperCamelCase    :  Any							=	decoder_layers
          UpperCamelCase    :  Union[str, Any]							=	scale_embedding  # scale factor will be sqrt(d_model) if True
          UpperCamelCase    :  Union[str, Any]							=	max_target_positions

          super().__init__(
              pad_token_id=SCREAMING_SNAKE_CASE_,			bos_token_id=SCREAMING_SNAKE_CASE_,			eos_token_id=SCREAMING_SNAKE_CASE_,			decoder_start_token_id=SCREAMING_SNAKE_CASE_,			**SCREAMING_SNAKE_CASE_,			)



