


import functools
import operator

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


lowerCamelCase__							:						str							     =   logging.get_logger(__name__)

lowerCamelCase__							:						Optional[int]							     =   {
    """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 		__magic_name__						(snake_case_				):





     '''simple docstring'''



     __lowercase				:							Tuple	   =       'unispeech'

     def __init__(					self:str     ,		_a:int=32     ,		_a:List[Any]=7_68     ,		_a:List[Any]=12     ,		_a:Optional[int]=12     ,		_a:str=30_72     ,		_a:Any="gelu"     ,		_a:List[str]=0.1     ,		_a:Optional[Any]=0.1     ,		_a:List[str]=0.1     ,		_a:Optional[Any]=0.0     ,		_a:Union[str, Any]=0.0     ,		_a:List[Any]=0.1     ,		_a:List[str]=0.1     ,		_a:Any=0.02     ,		_a:Optional[Any]=1e-5     ,		_a:List[str]="group"     ,		_a:Optional[int]="gelu"     ,		_a:List[str]=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)     ,		_a:str=(5, 2, 2, 2, 2, 2, 2)     ,		_a:Any=(10, 3, 3, 3, 3, 2, 2)     ,		_a:Any=False     ,		_a:List[Any]=1_28     ,		_a:List[Any]=16     ,		_a:Any=False     ,		_a:Optional[int]=True     ,		_a:Optional[int]=0.05     ,		_a:List[Any]=10     ,		_a:Any=2     ,		_a:Dict=0.0     ,		_a:List[str]=10     ,		_a:Dict=0     ,		_a:int=3_20     ,		_a:Union[str, Any]=2     ,		_a:str=0.1     ,		_a:Tuple=1_00     ,		_a:Optional[Any]=2_56     ,		_a:Optional[int]=2_56     ,		_a:Optional[int]=0.1     ,		_a:Union[str, Any]="mean"     ,		_a:Optional[Any]=False     ,		_a:List[Any]=False     ,		_a:Optional[Any]=2_56     ,		_a:Any=80     ,		_a:Optional[Any]=0     ,		_a:Optional[Any]=1     ,		_a:Any=2     ,		_a:Optional[int]=0.5     ,		**_a:List[str]     ,		):
       super().__init__(**_a     ,		pad_token_id=_a     ,		bos_token_id=_a     ,		eos_token_id=_a   )
       snake_case__						= hidden_size
       snake_case__						= feat_extract_norm
       snake_case__						= feat_extract_activation
       snake_case__						= list(_a   )
       snake_case__						= list(_a   )
       snake_case__						= list(_a   )
       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:str   ):
       return functools.reduce(operator.mul     ,		self.conv_stride     ,		1   )





from datasets.utils.patching import _PatchedModuleObj, patch_submodule

from . import _test_patching





def 						_lowerCAmelCase							(     )    ->						Tuple:


						'''simple docstring'''






						import os as original_os
						from os import path as original_path
						from os import rename as original_rename
						from os.path import dirname as original_dirname
						from os.path import join as original_join

						assert _test_patching.os is original_os
						assert _test_patching.path is original_path
						assert _test_patching.join is original_join

						assert _test_patching.renamed_os is original_os
						assert _test_patching.renamed_path is original_path
						assert _test_patching.renamed_join is original_join

						__snake_case				=		"__test_patch_submodule_mock__"
						with patch_submodule(_test_patching   ,						"os.path.join"   ,						_lowerCAmelCase			):
												# Every way to access os.path.join must be patched, and the rest must stay untouched

												# check os.path.join
												assert isinstance(_test_patching.os   ,						_PatchedModuleObj			)
												assert isinstance(_test_patching.os.path   ,						_PatchedModuleObj			)
												assert _test_patching.os.path.join is mock

												# check path.join
												assert isinstance(_test_patching.path   ,						_PatchedModuleObj			)
												assert _test_patching.path.join is mock

												# check join
												assert _test_patching.join is mock

												# check that the other attributes are untouched
												assert _test_patching.os.rename is original_rename
												assert _test_patching.path.dirname is original_dirname
												assert _test_patching.os.path.dirname is original_dirname

												# Even renamed modules or objects must be patched

												# check renamed_os.path.join
												assert isinstance(_test_patching.renamed_os   ,						_PatchedModuleObj			)
												assert isinstance(_test_patching.renamed_os.path   ,						_PatchedModuleObj			)
												assert _test_patching.renamed_os.path.join is mock

												# check renamed_path.join
												assert isinstance(_test_patching.renamed_path   ,						_PatchedModuleObj			)
												assert _test_patching.renamed_path.join is mock

												# check renamed_join
												assert _test_patching.renamed_join is mock

												# check that the other attributes are untouched
												assert _test_patching.renamed_os.rename is original_rename
												assert _test_patching.renamed_path.dirname is original_dirname
												assert _test_patching.renamed_os.path.dirname is original_dirname

						# check that everthing is back to normal when the patch is over

						assert _test_patching.os is original_os
						assert _test_patching.path is original_path
						assert _test_patching.join is original_join

						assert _test_patching.renamed_os is original_os
						assert _test_patching.renamed_path is original_path
						assert _test_patching.renamed_join is original_join





def 						_lowerCAmelCase							(     )    ->						int:


						'''simple docstring'''






						assert _test_patching.open is open

						__snake_case				=		"__test_patch_submodule_builtin_mock__"
						# _test_patching has "open" in its globals
						assert _test_patching.open is open
						with patch_submodule(_test_patching   ,						"open"   ,						_lowerCAmelCase			):
												assert _test_patching.open is mock

						# check that everthing is back to normal when the patch is over

						assert _test_patching.open is open





def 						_lowerCAmelCase							(     )    ->						Optional[Any]:


						'''simple docstring'''






						__snake_case				=		"__test_patch_submodule_missing_mock__"
						with patch_submodule(_test_patching   ,						"pandas.read_csv"   ,						_lowerCAmelCase			):
												pass





def 						_lowerCAmelCase							(     )    ->						Optional[Any]:


						'''simple docstring'''






						__snake_case				=		"__test_patch_submodule_missing_builtin_mock__"
						# _test_patching doesn't have "len" in its globals
						assert getattr(_test_patching   ,						"len"   ,						_lowerCAmelCase			) is None
						with patch_submodule(_test_patching   ,						"len"   ,						_lowerCAmelCase			):
												assert _test_patching.len is mock
						assert _test_patching.len is len





def 						_lowerCAmelCase							(     )    ->						Optional[Any]:


						'''simple docstring'''






						__snake_case				=		"__test_patch_submodule_start_and_stop_mock__"
						__snake_case				=		patch_submodule(_test_patching   ,						"open"   ,						_lowerCAmelCase			)
						assert _test_patching.open is open
						patch.start()
						assert _test_patching.open is mock
						patch.stop()
						assert _test_patching.open is open





def 						_lowerCAmelCase							(     )    ->						Any:


						'''simple docstring'''






						from os import rename as original_rename
						from os.path import dirname as original_dirname
						from os.path import join as original_join

						__snake_case				=		"__test_patch_submodule_successive_join__"
						__snake_case				=		"__test_patch_submodule_successive_dirname__"
						__snake_case				=		"__test_patch_submodule_successive_rename__"
						assert _test_patching.os.path.join is original_join
						assert _test_patching.os.path.dirname is original_dirname
						assert _test_patching.os.rename is original_rename

						with patch_submodule(_test_patching   ,						"os.path.join"   ,						_lowerCAmelCase			):
												with patch_submodule(_test_patching   ,						"os.rename"   ,						_lowerCAmelCase			):
																		with patch_submodule(_test_patching   ,						"os.path.dirname"   ,						_lowerCAmelCase			):
																								assert _test_patching.os.path.join is mock_join
																								assert _test_patching.os.path.dirname is mock_dirname
																								assert _test_patching.os.rename is mock_rename

    # try another order
						with patch_submodule(_test_patching   ,						"os.rename"   ,						_lowerCAmelCase			):
												with patch_submodule(_test_patching   ,						"os.path.join"   ,						_lowerCAmelCase			):
																		with patch_submodule(_test_patching   ,						"os.path.dirname"   ,						_lowerCAmelCase			):
																								assert _test_patching.os.path.join is mock_join
																								assert _test_patching.os.path.dirname is mock_dirname
																								assert _test_patching.os.rename is mock_rename

						assert _test_patching.os.path.join is original_join
						assert _test_patching.os.path.dirname is original_dirname
						assert _test_patching.os.rename is original_rename





def 						_lowerCAmelCase							(     )    ->						str:


						'''simple docstring'''






						__snake_case				=		"__test_patch_submodule_doesnt_exist_mock__"
						with patch_submodule(_test_patching   ,						"__module_that_doesn_exist__.__attribute_that_doesn_exist__"   ,						_lowerCAmelCase			):
												pass
						with patch_submodule(_test_patching   ,						"os.__attribute_that_doesn_exist__"   ,						_lowerCAmelCase			):
												pass





