

'''simple docstring'''





import functools
import operator

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


UpperCamelCase_							=					logging.get_logger(__name__)

UpperCamelCase_							=					{
    """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 		__SCREAMING_SNAKE_CASE       ( lowercase__			):
				lowerCamelCase_							=						'wav2vec2'







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

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

										# ctc loss
										lowercase   :       Tuple								=ctc_loss_reduction
										lowercase   :       Optional[Any]								=ctc_zero_infinity

										# adapter
										lowercase   :       Dict								=add_adapter
										lowercase   :       str								=adapter_kernel_size
										lowercase   :       Optional[Any]								=adapter_stride
										lowercase   :       Union[str, Any]								=num_adapter_layers
										lowercase   :       Union[str, Any]								=output_hidden_size or hidden_size
										lowercase   :       Dict								=adapter_attn_dim

										# SequenceClassification-specific parameter. Feel free to ignore for other classes.
										lowercase   :       Union[str, Any]								=classifier_proj_size

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







				@property
				def    lowerCamelCase_  (					self    :		Any      ):
										'''simple docstring'''
										return functools.reduce(operator.mul		,				self.conv_stride		,				1      )








'''simple docstring'''





import math






def 							_lowerCAmelCase (      __magic_name__	:    float      ,   __magic_name__	:    float	)							->     float:
						if (
						    not isinstance(__magic_name__      ,   (int, float)	)
						    or power_factor < -1
						    or power_factor > 1
						):
												raise ValueError('''power_factor must be a valid float value between -1 and 1.'''	)
						return apparent_power * power_factor






def 							_lowerCAmelCase (      __magic_name__	:    float      ,   __magic_name__	:    float	)							->     float:
						if (
						    not isinstance(__magic_name__      ,   (int, float)	)
						    or power_factor < -1
						    or power_factor > 1
						):
												raise ValueError('''power_factor must be a valid float value between -1 and 1.'''	)
						return apparent_power * math.sqrt(1 - power_factor**2	)


if __name__ == "__main__":
							import doctest

							doctest.testmod()





