



import functools
import operator

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


UpperCAmelCase_							:      Optional[Any]      =  logging.get_logger(__name__)

UpperCAmelCase_							:      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      UpperCamelCase    (						_UpperCAmelCase     ):
	lowerCAmelCase	:   Optional[Any]				=	"""unispeech-sat"""



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

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

							# ctc loss
							A__							=       ctc_loss_reduction
							A__							=       ctc_zero_infinity

							# SequenceClassification-specific parameter. Feel free to ignore for other classes.
							A__							=       classifier_proj_size

							# XVector-specific parameters. Feel free to ignore for other classes.
							A__							=       list(UpperCAmelCase__		)
							A__							=       list(UpperCAmelCase__		)
							A__							=       list(UpperCAmelCase__		)
							A__							=       xvector_output_dim



	@property
	def 			__A							(       self		):
							return functools.reduce(operator.mul			,	self.conv_stride			,	1		)










from .dependency_versions_table import deps
from .utils.versions import require_version, require_version_core


# define which module versions we always want to check at run time
# (usually the ones defined in `install_requires` in setup.py)
#
# order specific notes:
# - tqdm must be checked before tokenizers

UpperCAmelCase_							:      List[Any]      =  [
    "python",
    "tqdm",
    "regex",
    "requests",
    "packaging",
    "filelock",
    "numpy",
    "tokenizers",
    "huggingface-hub",
    "safetensors",
    "accelerate",
    "pyyaml",
]

for pkg in pkgs_to_check_at_runtime:
						if pkg in deps:
												if pkg == "tokenizers":
																		# must be loaded here, or else tqdm check may fail
																		from .utils import is_tokenizers_available

																		if not is_tokenizers_available():
																								continue  # not required, check version only if installed
												elif pkg == "accelerate":
																		# must be loaded here, or else tqdm check may fail
																		from .utils import is_accelerate_available

																		# Maybe switch to is_torch_available in the future here so that Accelerate is hard dep of
																		# Transformers with PyTorch
																		if not is_accelerate_available():
																								continue  # not required, check version only if installed

												require_version_core(deps[pkg])
						else:
												raise ValueError(F'''can\'t find {pkg} in {deps.keys()}, check dependency_versions_table.py''')
def  UpperCamelCase						(       _A			:				List[Any]			,							_A			:				int=None    )->       Optional[int]:





						"""simple docstring"""





						require_version(deps[pkg]			,							_A    )





