


import functools
import operator

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


A							:					Any     						=     logging.get_logger(__name__)

A							:					List[str]     						=     {
    '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     UpperCamelCase(  _a   ):
					snake_case_		:				List[Any]										=	"""wav2vec2"""


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




											'''simple docstring'''

											super().__init__(**SCREAMING_SNAKE_CASE     ,    pad_token_id=SCREAMING_SNAKE_CASE     ,    bos_token_id=SCREAMING_SNAKE_CASE     ,    eos_token_id=SCREAMING_SNAKE_CASE						)
											__snake_case				=		hidden_size
											__snake_case				=		feat_extract_norm
											__snake_case				=		feat_extract_activation
											__snake_case				=		list(SCREAMING_SNAKE_CASE						)
											__snake_case				=		list(SCREAMING_SNAKE_CASE						)
											__snake_case				=		list(SCREAMING_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(SCREAMING_SNAKE_CASE						)
											__snake_case				=		list(SCREAMING_SNAKE_CASE						)
											__snake_case				=		list(SCREAMING_SNAKE_CASE						)
											__snake_case				=		xvector_output_dim






					@property
					def 							SCREAMING_SNAKE_CASE_  (						self	:		Optional[Any]						)			->	Any:




											'''simple docstring'''

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









from sklearn.metrics import mean_squared_error

import datasets


A							:					List[Any]     						=     '\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.\n         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and\n         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},\n journal={Journal of Machine Learning Research},\n volume={12},\n pages={2825--2830},\n year={2011}\n}\n'

A							:					Optional[int]     						=     '\\nMean Squared Error(MSE) is the average of the square of difference between the predicted\nand actual values.\n'


A							:					str     						=     '\nArgs:\n    predictions: array-like of shape (n_samples,) or (n_samples, n_outputs)\n        Estimated target values.\n    references: array-like of shape (n_samples,) or (n_samples, n_outputs)\n        Ground truth (correct) target values.\n    sample_weight: array-like of shape (n_samples,), default=None\n        Sample weights.\n    multioutput: {"raw_values", "uniform_average"} or array-like of shape (n_outputs,), default="uniform_average"\n        Defines aggregating of multiple output values. Array-like value defines weights used to average errors.\n\n        "raw_values" : Returns a full set of errors in case of multioutput input.\n\n        "uniform_average" : Errors of all outputs are averaged with uniform weight.\n\n    squared : bool, default=True\n        If True returns MSE value, if False returns RMSE (Root Mean Squared Error) value.\n\nReturns:\n    mse : mean squared error.\nExamples:\n\n    >>> mse_metric = datasets.load_metric("mse")\n    >>> predictions = [2.5, 0.0, 2, 8]\n    >>> references = [3, -0.5, 2, 7]\n    >>> results = mse_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {\'mse\': 0.375}\n    >>> rmse_result = mse_metric.compute(predictions=predictions, references=references, squared=False)\n    >>> print(rmse_result)\n    {\'mse\': 0.6123724356957945}\n\n    If you\'re using multi-dimensional lists, then set the config as follows :\n\n    >>> mse_metric = datasets.load_metric("mse", "multilist")\n    >>> predictions = [[0.5, 1], [-1, 1], [7, -6]]\n    >>> references = [[0, 2], [-1, 2], [8, -5]]\n    >>> results = mse_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {\'mse\': 0.7083333333333334}\n    >>> results = mse_metric.compute(predictions=predictions, references=references, multioutput=\'raw_values\')\n    >>> print(results) # doctest: +NORMALIZE_WHITESPACE\n    {\'mse\': array([0.41666667, 1. ])}\n'






@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION     ,							_KWARGS_DESCRIPTION   )
class     UpperCamelCase(  datasets.Metric   ):


					def 							SCREAMING_SNAKE_CASE_  (						self	:		Dict						)			->	Union[str, Any]:




											'''simple docstring'''

											return datasets.MetricInfo(
											    description=_DESCRIPTION     ,    citation=_CITATION     ,    inputs_description=_KWARGS_DESCRIPTION     ,    features=datasets.Features(self._get_feature_types()						)     ,    reference_urls=[
											        "https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html"
											    ]     ,    )


					def 							SCREAMING_SNAKE_CASE_  (						self	:		List[str]						)			->	Dict:




											'''simple docstring'''

											if self.config_name == "multilist":
																	return {
																	    "predictions": datasets.Sequence(datasets.Value("float"						)						),
																	    "references": datasets.Sequence(datasets.Value("float"						)						),
																	}
											else:
																	return {
																	    "predictions": datasets.Value("float"						),
																	    "references": datasets.Value("float"						),
																	}






					def 							SCREAMING_SNAKE_CASE_  (						self	:		Dict     ,    SCREAMING_SNAKE_CASE	:		int     ,    SCREAMING_SNAKE_CASE	:		List[Any]     ,    SCREAMING_SNAKE_CASE	:		str=None     ,    SCREAMING_SNAKE_CASE	:		int="uniform_average"     ,    SCREAMING_SNAKE_CASE	:		Optional[int]=True						)			->	Tuple:




											'''simple docstring'''

											__snake_case				=		mean_squared_error(
											    SCREAMING_SNAKE_CASE     ,    SCREAMING_SNAKE_CASE     ,    sample_weight=SCREAMING_SNAKE_CASE     ,    multioutput=SCREAMING_SNAKE_CASE     ,    squared=SCREAMING_SNAKE_CASE						)

											return {"mse": mse}





