

'''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		(__SCREAMING_SNAKE_CASE):
			__A  :	Dict        ="wav2vec2"






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

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

				# ctc loss
				UpperCAmelCase_     :      int						=  ctc_loss_reduction
				UpperCAmelCase_     :      int						=  ctc_zero_infinity

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

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

				# XVector-specific parameters. Feel free to ignore for other classes.
				UpperCAmelCase_     :      Tuple						=  list(__a     )
				UpperCAmelCase_     :      Union[str, Any]						=  list(__a     )
				UpperCAmelCase_     :      Tuple						=  list(__a     )
				UpperCAmelCase_     :      List[str]						=  xvector_output_dim






			@property
			def 		UpperCamelCase__							(  self     ):
				return functools.reduce(operator.mul			,self.conv_stride			,1     )





'''simple docstring'''


from collections.abc import Callable
from math import pi, sqrt
from random import uniform
from statistics import mean





def    lowerCAmelCase       (		UpperCamelCase__					: int							):


	"""simple docstring"""

	# A local function to see if a dot lands in the circle.
	def is_in_circle(UpperCamelCase__					: float     ,       UpperCamelCase__					: float							) -> bool:
		__UpperCAmelCase      					=      sqrt((x**2) + (y**2)							)
		# Our circle has a radius of 1, so a distance
		# greater than 1 would land outside the circle.
		return distance_from_centre <= 1

	# The proportion of guesses that landed in the circle
	__UpperCAmelCase      					=      mean(
	    int(is_in_circle(uniform(-1.0     ,       1.0							)     ,       uniform(-1.0     ,       1.0							)							)							)
	    for _ in range(UpperCamelCase__							)							)
	# The ratio of the area for circle to square is pi/4.
	__UpperCAmelCase      					=      proportion * 4
	print(f"""The estimated value of pi is {pi_estimate}"""							)
	print(f"""The numpy value of pi is {pi}"""							)
	print(f"""The total error is {abs(pi - pi_estimate							)}"""							)





def    lowerCAmelCase       (		UpperCamelCase__					: int     ,       UpperCamelCase__					: Callable[[float], float]     ,       UpperCamelCase__					: float = 0.0     ,       UpperCamelCase__					: float = 1.0     ,       ):


	"""simple docstring"""
	return mean(
	    function_to_integrate(uniform(UpperCamelCase__     ,       UpperCamelCase__							)							) for _ in range(UpperCamelCase__							)							) * (max_value - min_value)





def    lowerCAmelCase       (		UpperCamelCase__					: int     ,       UpperCamelCase__					: float = 0.0     ,       UpperCamelCase__					: float = 1.0							):


	"""simple docstring"""

	def identity_function(UpperCamelCase__					: float							) -> float:
		return x

	__UpperCAmelCase      					=      area_under_curve_estimator(
	    UpperCamelCase__     ,       UpperCamelCase__     ,       UpperCamelCase__     ,       UpperCamelCase__							)
	__UpperCAmelCase      					=      (max_value * max_value - min_value * min_value) / 2

	print('''******************'''							)
	print(f"""Estimating area under y=x where x varies from {min_value} to {max_value}"""							)
	print(f"""Estimated value is {estimated_value}"""							)
	print(f"""Expected value is {expected_value}"""							)
	print(f"""Total error is {abs(estimated_value - expected_value							)}"""							)
	print('''******************'''							)





def    lowerCAmelCase       (		UpperCamelCase__					: int							):


	"""simple docstring"""

	def function_to_integrate(UpperCamelCase__					: float							) -> float:
		return sqrt(4.0 - x * x							)

	__UpperCAmelCase      					=      area_under_curve_estimator(
	    UpperCamelCase__     ,       UpperCamelCase__     ,       0.0     ,       2.0							)

	print('''******************'''							)
	print('''Estimating pi using area_under_curve_estimator'''							)
	print(f"""Estimated value is {estimated_value}"""							)
	print(f"""Expected value is {pi}"""							)
	print(f"""Total error is {abs(estimated_value - pi							)}"""							)
	print('''******************'''							)


if __name__ == "__main__":
					import doctest

					doctest.testmod()
