





import functools
import operator

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


SCREAMING_SNAKE_CASE_   :      str			=   logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_   :      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 		snake_case_   (							UpperCAmelCase_						):







	'''simple docstring'''
	__UpperCamelCase   =		'''unispeech'''




	def __init__(						self							:     int					,      __lowerCamelCase							:     Any=32					,      __lowerCamelCase							:     Any=768					,      __lowerCamelCase							:     Optional[Any]=12					,      __lowerCamelCase							:     int=12					,      __lowerCamelCase							:     List[str]=3_072					,      __lowerCamelCase							:     Union[str, Any]="gelu"					,      __lowerCamelCase							:     Any=0.1					,      __lowerCamelCase							:     Union[str, Any]=0.1					,      __lowerCamelCase							:     Any=0.1					,      __lowerCamelCase							:     List[Any]=0.0					,      __lowerCamelCase							:     Union[str, Any]=0.0					,      __lowerCamelCase							:     Union[str, Any]=0.1					,      __lowerCamelCase							:     List[Any]=0.1					,      __lowerCamelCase							:     Dict=0.02					,      __lowerCamelCase							:     List[str]=1E-5					,      __lowerCamelCase							:     str="group"					,      __lowerCamelCase							:     Union[str, Any]="gelu"					,      __lowerCamelCase							:     str=(512, 512, 512, 512, 512, 512, 512)					,      __lowerCamelCase							:     Tuple=(5, 2, 2, 2, 2, 2, 2)					,      __lowerCamelCase							:     List[Any]=(10, 3, 3, 3, 3, 2, 2)					,      __lowerCamelCase							:     List[Any]=False					,      __lowerCamelCase							:     List[Any]=128					,      __lowerCamelCase							:     List[str]=16					,      __lowerCamelCase							:     int=False					,      __lowerCamelCase							:     Any=True					,      __lowerCamelCase							:     Optional[Any]=0.05					,      __lowerCamelCase							:     Optional[Any]=10					,      __lowerCamelCase							:     Optional[Any]=2					,      __lowerCamelCase							:     Dict=0.0					,      __lowerCamelCase							:     Dict=10					,      __lowerCamelCase							:     Dict=0					,      __lowerCamelCase							:     Tuple=320					,      __lowerCamelCase							:     Optional[Any]=2					,      __lowerCamelCase							:     Dict=0.1					,      __lowerCamelCase							:     Optional[int]=100					,      __lowerCamelCase							:     int=256					,      __lowerCamelCase							:     Optional[int]=256					,      __lowerCamelCase							:     Optional[Any]=0.1					,      __lowerCamelCase							:     Optional[Any]="mean"					,      __lowerCamelCase							:     int=False					,      __lowerCamelCase							:     Optional[Any]=False					,      __lowerCamelCase							:     int=256					,      __lowerCamelCase							:     Optional[Any]=80					,      __lowerCamelCase							:     Optional[Any]=0					,      __lowerCamelCase							:     List[str]=1					,      __lowerCamelCase							:     Tuple=2					,      __lowerCamelCase							:     List[Any]=0.5					,      **__lowerCamelCase							:     Optional[Any]					,      )       -> List[Any]:

			'''simple docstring'''




			super().__init__(**__lowerCamelCase					,      pad_token_id=__lowerCamelCase					,      bos_token_id=__lowerCamelCase					,      eos_token_id=__lowerCamelCase   )
			__lowercase											=     hidden_size
			__lowercase											=     feat_extract_norm
			__lowercase											=     feat_extract_activation
			__lowercase											=     list(__lowerCamelCase   )
			__lowercase											=     list(__lowerCamelCase   )
			__lowercase											=     list(__lowerCamelCase   )
			__lowercase											=     conv_bias
			__lowercase											=     num_conv_pos_embeddings
			__lowercase											=     num_conv_pos_embedding_groups
			__lowercase											=     len(self.conv_dim   )
			__lowercase											=     num_hidden_layers
			__lowercase											=     intermediate_size
			__lowercase											=     hidden_act
			__lowercase											=     num_attention_heads
			__lowercase											=     hidden_dropout
			__lowercase											=     attention_dropout
			__lowercase											=     activation_dropout
			__lowercase											=     feat_proj_dropout
			__lowercase											=     final_dropout
			__lowercase											=     layerdrop
			__lowercase											=     layer_norm_eps
			__lowercase											=     initializer_range
			__lowercase											=     num_ctc_classes
			__lowercase											=     vocab_size
			__lowercase											=     do_stable_layer_norm
			__lowercase											=     use_weighted_layer_sum
			__lowercase											=     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
			__lowercase											=     apply_spec_augment
			__lowercase											=     mask_time_prob
			__lowercase											=     mask_time_length
			__lowercase											=     mask_time_min_masks
			__lowercase											=     mask_feature_prob
			__lowercase											=     mask_feature_length
			__lowercase											=     mask_feature_min_masks

			# parameters for pretraining with codevector quantized representations
			__lowercase											=     num_codevectors_per_group
			__lowercase											=     num_codevector_groups
			__lowercase											=     contrastive_logits_temperature
			__lowercase											=     feat_quantizer_dropout
			__lowercase											=     num_negatives
			__lowercase											=     codevector_dim
			__lowercase											=     proj_codevector_dim
			__lowercase											=     diversity_loss_weight

			# ctc loss
			__lowercase											=     ctc_loss_reduction
			__lowercase											=     ctc_zero_infinity

			# pretraining loss
			__lowercase											=     replace_prob






	@property
	def    UpperCAmelCase			(						self							:     Optional[int]   )       -> List[Any]:

			'''simple docstring'''




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











SCREAMING_SNAKE_CASE_   :      dict[str, float]			=   {
    "joule": 1.0,
    "kilojoule": 1000,
    "megajoule": 100_0000,
    "gigajoule": 10_0000_0000,
    "wattsecond": 1.0,
    "watthour": 3600,
    "kilowatthour": 360_0000,
    "newtonmeter": 1.0,
    "calorie_nutr": 4186.8,
    "kilocalorie_nutr": 418_6800.00,
    "electronvolt": 1.6_0_2_1_7_6_6_3_4e-1_9,
    "britishthermalunit_it": 1055.0_5585,
    "footpound": 1.35_5818,
}



def  SCREAMING_SNAKE_CASE				(      snake_case						,   snake_case						,   snake_case							)		->    float:
		if to_type not in ENERGY_CONVERSION or from_type not in ENERGY_CONVERSION:
				__lowercase											=     (
				    F"Incorrect 'from_type' or 'to_type' value: {from_type!r}, {to_type!r}\n"
				    F"Valid values are: {', '.join(snake_case							)}"
				)
				raise ValueError(snake_case							)
		return value * ENERGY_CONVERSION[from_type] / ENERGY_CONVERSION[to_type]


if __name__ == "__main__":
		import doctest

		doctest.testmod()




