


import functools
import operator

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


snake_case    :   List[Any]	    =					logging.get_logger(__name__)

snake_case    :   Any	    =					{
    '''microsoft/unispeech-sat-base-100h-libri-ft''': (
        '''https://huggingface.co/microsoft/unispeech-sat-base-100h-libri-ft/resolve/main/config.json'''
    ),
    # See all UniSpeechSat models at https://huggingface.co/models?filter=unispeech_sat
}







class 		_snake_case  (				_UpperCAmelCase							):
 SCREAMING_SNAKE_CASE__				=	"unispeech-sat"




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

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

       # ctc loss
       a						:int										=	ctc_loss_reduction
       a						:Union[str, Any]										=	ctc_zero_infinity

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

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




 @property
 def 	SCREAMING_SNAKE_CASE__    (		self   ):
       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,
)


snake_case    :   Any	    =					pytest.mark.integration
@pytest.mark.parametrize('''path'''			,  ['''paws''', '''csv''']						)
def     __lowerCamelCase						(			UpperCAmelCase_						:		Optional[int]			,  UpperCAmelCase_						:		Optional[Any]						):




      """simple docstring"""





      inspect_dataset(UpperCAmelCase_			,  UpperCAmelCase_						)
      a						:List[Any]										=	path + '''.py'''
      assert script_name in os.listdir(UpperCAmelCase_						)
      assert "__pycache__" not in os.listdir(UpperCAmelCase_						)
@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						(			UpperCAmelCase_						:		List[Any]			,  UpperCAmelCase_						:		Any						):




      """simple docstring"""





      inspect_metric(UpperCAmelCase_			,  UpperCAmelCase_						)
      a						:Dict										=	path + '''.py'''
      assert script_name in os.listdir(UpperCAmelCase_						)
      assert "__pycache__" not in os.listdir(UpperCAmelCase_						)
@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						(			UpperCAmelCase_						:		Optional[int]			,  UpperCAmelCase_						:		List[Any]			,  UpperCAmelCase_						:		str						):




      """simple docstring"""





      a						:List[str]										=	get_dataset_config_info(UpperCAmelCase_			,  config_name=UpperCAmelCase_						)
      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						(			UpperCAmelCase_						:		List[Any]			,  UpperCAmelCase_						:		str			,  UpperCAmelCase_						:		Tuple						):




      """simple docstring"""





      with pytest.raises(UpperCAmelCase_						):
            get_dataset_config_info(UpperCAmelCase_			,  config_name=UpperCAmelCase_						)
@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						(			UpperCAmelCase_						:		Tuple			,  UpperCAmelCase_						:		int						):




      """simple docstring"""





      a						:List[str]										=	get_dataset_config_names(UpperCAmelCase_						)
      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						(			UpperCAmelCase_						:		Tuple			,  UpperCAmelCase_						:		Tuple			,  UpperCAmelCase_						:		Optional[int]						):




      """simple docstring"""





      a						:Optional[int]										=	get_dataset_infos(UpperCAmelCase_						)
      assert list(infos.keys()						) == expected_configs
      a						:Union[str, Any]										=	expected_configs[0]
      assert expected_config in infos
      a						:List[Any]										=	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						(			UpperCAmelCase_						:		Optional[int]			,  UpperCAmelCase_						:		Any			,  UpperCAmelCase_						:		Optional[int]						):




      """simple docstring"""





      a						:Union[str, Any]										=	get_dataset_infos(UpperCAmelCase_						)
      assert expected_config in infos
      a						:int										=	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						(			UpperCAmelCase_						:		Union[str, Any]			,  UpperCAmelCase_						:		Optional[int]			,  UpperCAmelCase_						:		str						):




      """simple docstring"""





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





