


import functools
import operator

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


A				:       Dict      =  logging.get_logger(__name__)

A				:       List[Any]      =  {
    'microsoft/unispeech-large-1500h-cv': (
        'https://huggingface.co/microsoft/unispeech-large-1500h-cv/resolve/main/config.json'
    ),
    # See all UniSpeech models at https://huggingface.co/models?filter=unispeech
}






class      UpperCamelCase(	_a ):
					snake_case_		:					List[str]    					=						"""unispeech"""


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




											'''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				=		num_ctc_classes
											__snake_case				=		vocab_size
											__snake_case				=		do_stable_layer_norm
											__snake_case				=		use_weighted_layer_sum
											__snake_case				=		classifier_proj_size

											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

											# pretraining loss
											__snake_case				=		replace_prob






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




											'''simple docstring'''

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









import os

import pytest

from datasets import (
    get_dataset_config_info,
    get_dataset_config_names,
    get_dataset_infos,
    get_dataset_split_names,
    inspect_dataset,
    inspect_metric,
)


A				:       List[str]      =  pytest.mark.integration





@pytest.mark.parametrize("path"   ,						["paws", "csv"]			)
def 						_lowerCAmelCase							(     _lowerCAmelCase   ,						_lowerCAmelCase			)    ->						Any:


						'''simple docstring'''






						inspect_dataset(_lowerCAmelCase   ,						_lowerCAmelCase			)
						__snake_case				=		path + ".py"
						assert script_name in os.listdir(_lowerCAmelCase			)
						assert "__pycache__" not in os.listdir(_lowerCAmelCase			)





@pytest.mark.filterwarnings("ignore:inspect_metric is deprecated:FutureWarning"			)
@pytest.mark.filterwarnings("ignore:metric_module_factory is deprecated:FutureWarning"			)
@pytest.mark.parametrize("path"   ,						["accuracy"]			)
def 						_lowerCAmelCase							(     _lowerCAmelCase   ,						_lowerCAmelCase			)    ->						List[str]:


						'''simple docstring'''






						inspect_metric(_lowerCAmelCase   ,						_lowerCAmelCase			)
						__snake_case				=		path + ".py"
						assert script_name in os.listdir(_lowerCAmelCase			)
						assert "__pycache__" not in os.listdir(_lowerCAmelCase			)





@pytest.mark.parametrize(
    "path, config_name, expected_splits"   ,						[
        ("squad", "plain_text", ["train", "validation"]),
        ("dalle-mini/wit", "dalle-mini--wit", ["train"]),
        ("paws", "labeled_final", ["train", "test", "validation"]),
    ]   ,						)
def 						_lowerCAmelCase							(     _lowerCAmelCase   ,						_lowerCAmelCase   ,						_lowerCAmelCase			)    ->						List[Any]:


						'''simple docstring'''






						__snake_case				=		get_dataset_config_info(_lowerCAmelCase   ,						config_name=_lowerCAmelCase			)
						assert info.config_name == config_name
						assert list(info.splits.keys()			) == expected_splits





@pytest.mark.parametrize(
    "path, config_name, expected_exception"   ,						[
        ("paws", None, ValueError),
    ]   ,						)
def 						_lowerCAmelCase							(     _lowerCAmelCase   ,						_lowerCAmelCase   ,						_lowerCAmelCase			)    ->						Tuple:


						'''simple docstring'''






						with pytest.raises(_lowerCAmelCase			):
												get_dataset_config_info(_lowerCAmelCase   ,						config_name=_lowerCAmelCase			)





@pytest.mark.parametrize(
    "path, expected"   ,						[
        ("squad", "plain_text"),
        ("acronym_identification", "default"),
        ("lhoestq/squad", "plain_text"),
        ("lhoestq/test", "default"),
        ("lhoestq/demo1", "lhoestq--demo1"),
        ("dalle-mini/wit", "dalle-mini--wit"),
    ]   ,						)
def 						_lowerCAmelCase							(     _lowerCAmelCase   ,						_lowerCAmelCase			)    ->						Tuple:


						'''simple docstring'''






						__snake_case				=		get_dataset_config_names(_lowerCAmelCase			)
						assert expected in config_names





@pytest.mark.parametrize(
    "path, expected_configs, expected_splits_in_first_config"   ,						[
        ("squad", ["plain_text"], ["train", "validation"]),
        ("dalle-mini/wit", ["dalle-mini--wit"], ["train"]),
        ("paws", ["labeled_final", "labeled_swap", "unlabeled_final"], ["train", "test", "validation"]),
    ]   ,						)
def 						_lowerCAmelCase							(     _lowerCAmelCase   ,						_lowerCAmelCase   ,						_lowerCAmelCase			)    ->						Any:


						'''simple docstring'''






						__snake_case				=		get_dataset_infos(_lowerCAmelCase			)
						assert list(infos.keys()			) == expected_configs
						__snake_case				=		expected_configs[0]
						assert expected_config in infos
						__snake_case				=		infos[expected_config]
						assert info.config_name == expected_config
						assert list(info.splits.keys()			) == expected_splits_in_first_config





@pytest.mark.parametrize(
    "path, expected_config, expected_splits"   ,						[
        ("squad", "plain_text", ["train", "validation"]),
        ("dalle-mini/wit", "dalle-mini--wit", ["train"]),
        ("paws", "labeled_final", ["train", "test", "validation"]),
    ]   ,						)
def 						_lowerCAmelCase							(     _lowerCAmelCase   ,						_lowerCAmelCase   ,						_lowerCAmelCase			)    ->						int:


						'''simple docstring'''






						__snake_case				=		get_dataset_infos(_lowerCAmelCase			)
						assert expected_config in infos
						__snake_case				=		infos[expected_config]
						assert info.config_name == expected_config
						assert list(info.splits.keys()			) == expected_splits





@pytest.mark.parametrize(
    "path, config_name, expected_exception"   ,						[
        ("paws", None, ValueError),
    ]   ,						)
def 						_lowerCAmelCase							(     _lowerCAmelCase   ,						_lowerCAmelCase   ,						_lowerCAmelCase			)    ->						str:


						'''simple docstring'''






						with pytest.raises(_lowerCAmelCase			):
												get_dataset_split_names(_lowerCAmelCase   ,						config_name=_lowerCAmelCase			)





