
import functools
import operator

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


UpperCAmelCase__   :					str												=				logging.get_logger(__name__)

UpperCAmelCase__   :					Dict												=				{
    '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 			lowerCAmelCase_		(a__						):


				"""simple docstring"""



				__UpperCamelCase   :		List[str]       =     '''unispeech'''



				def __init__(self     , SCREAMING_SNAKE_CASE__=32     , SCREAMING_SNAKE_CASE__=7_68     , SCREAMING_SNAKE_CASE__=12     , SCREAMING_SNAKE_CASE__=12     , SCREAMING_SNAKE_CASE__=30_72     , SCREAMING_SNAKE_CASE__="gelu"     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__=0.0     , SCREAMING_SNAKE_CASE__=0.0     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__=0.02     , SCREAMING_SNAKE_CASE__=1E-5     , SCREAMING_SNAKE_CASE__="group"     , SCREAMING_SNAKE_CASE__="gelu"     , SCREAMING_SNAKE_CASE__=(5_12, 5_12, 5_12, 5_12, 5_12, 5_12, 5_12)     , SCREAMING_SNAKE_CASE__=(5, 2, 2, 2, 2, 2, 2)     , SCREAMING_SNAKE_CASE__=(10, 3, 3, 3, 3, 2, 2)     , SCREAMING_SNAKE_CASE__=False     , SCREAMING_SNAKE_CASE__=1_28     , SCREAMING_SNAKE_CASE__=16     , SCREAMING_SNAKE_CASE__=False     , SCREAMING_SNAKE_CASE__=True     , SCREAMING_SNAKE_CASE__=0.05     , SCREAMING_SNAKE_CASE__=10     , SCREAMING_SNAKE_CASE__=2     , SCREAMING_SNAKE_CASE__=0.0     , SCREAMING_SNAKE_CASE__=10     , SCREAMING_SNAKE_CASE__=0     , SCREAMING_SNAKE_CASE__=3_20     , SCREAMING_SNAKE_CASE__=2     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__=1_00     , SCREAMING_SNAKE_CASE__=2_56     , SCREAMING_SNAKE_CASE__=2_56     , SCREAMING_SNAKE_CASE__=0.1     , SCREAMING_SNAKE_CASE__="mean"     , SCREAMING_SNAKE_CASE__=False     , SCREAMING_SNAKE_CASE__=False     , SCREAMING_SNAKE_CASE__=2_56     , SCREAMING_SNAKE_CASE__=80     , SCREAMING_SNAKE_CASE__=0     , SCREAMING_SNAKE_CASE__=1     , SCREAMING_SNAKE_CASE__=2     , SCREAMING_SNAKE_CASE__=0.5     , **SCREAMING_SNAKE_CASE__     , )      ->	List[Any]:



											"""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__					)
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     hidden_size
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     feat_extract_norm
											SCREAMING_SNAKE_CASE__		: Any     =     feat_extract_activation
											SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     list(SCREAMING_SNAKE_CASE__					)
											SCREAMING_SNAKE_CASE__		: str     =     list(SCREAMING_SNAKE_CASE__					)
											SCREAMING_SNAKE_CASE__		: Tuple     =     list(SCREAMING_SNAKE_CASE__					)
											SCREAMING_SNAKE_CASE__		: List[str]     =     conv_bias
											SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     num_conv_pos_embeddings
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     num_conv_pos_embedding_groups
											SCREAMING_SNAKE_CASE__		: Dict     =     len(self.conv_dim					)
											SCREAMING_SNAKE_CASE__		: List[str]     =     num_hidden_layers
											SCREAMING_SNAKE_CASE__		: str     =     intermediate_size
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     hidden_act
											SCREAMING_SNAKE_CASE__		: Any     =     num_attention_heads
											SCREAMING_SNAKE_CASE__		: Dict     =     hidden_dropout
											SCREAMING_SNAKE_CASE__		: List[str]     =     attention_dropout
											SCREAMING_SNAKE_CASE__		: Any     =     activation_dropout
											SCREAMING_SNAKE_CASE__		: int     =     feat_proj_dropout
											SCREAMING_SNAKE_CASE__		: List[Any]     =     final_dropout
											SCREAMING_SNAKE_CASE__		: str     =     layerdrop
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     layer_norm_eps
											SCREAMING_SNAKE_CASE__		: Dict     =     initializer_range
											SCREAMING_SNAKE_CASE__		: Dict     =     num_ctc_classes
											SCREAMING_SNAKE_CASE__		: List[Any]     =     vocab_size
											SCREAMING_SNAKE_CASE__		: str     =     do_stable_layer_norm
											SCREAMING_SNAKE_CASE__		: Dict     =     use_weighted_layer_sum
											SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     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
											SCREAMING_SNAKE_CASE__		: Tuple     =     apply_spec_augment
											SCREAMING_SNAKE_CASE__		: Optional[int]     =     mask_time_prob
											SCREAMING_SNAKE_CASE__		: Optional[Any]     =     mask_time_length
											SCREAMING_SNAKE_CASE__		: List[str]     =     mask_time_min_masks
											SCREAMING_SNAKE_CASE__		: Tuple     =     mask_feature_prob
											SCREAMING_SNAKE_CASE__		: Any     =     mask_feature_length
											SCREAMING_SNAKE_CASE__		: int     =     mask_feature_min_masks

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

											# ctc loss
											SCREAMING_SNAKE_CASE__		: int     =     ctc_loss_reduction
											SCREAMING_SNAKE_CASE__		: str     =     ctc_zero_infinity

											# pretraining loss
											SCREAMING_SNAKE_CASE__		: List[str]     =     replace_prob



				@property
				def 			__magic_name__					(self					)      ->	Tuple:



											"""simple docstring"""




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






"""simple docstring"""




import os
import zipfile

import requests
from get_ci_error_statistics import download_artifact, get_artifacts_links

def lowercase_						(     _snake_case     ,_snake_case=7		):
							SCREAMING_SNAKE_CASE__		: Dict     =     None
							if token is not None:
														SCREAMING_SNAKE_CASE__		: str     =     {"""Accept""": """application/vnd.github+json""", """Authorization""": f'''Bearer {token}'''}

							# The id of a workflow (not of a workflow run)
							SCREAMING_SNAKE_CASE__		: List[str]     =     """636036"""

							SCREAMING_SNAKE_CASE__		: Any     =     f'''https://api.github.com/repos/huggingface/transformers/actions/workflows/{workflow_id}/runs'''
							# On `main` branch + event being `schedule` + not returning PRs + only `num_runs` results
							url += f'''?branch=main&event=schedule&exclude_pull_requests=true&per_page={num_runs}'''

							SCREAMING_SNAKE_CASE__		: str     =     requests.get(_snake_case     ,headers=_snake_case		).json()

							return result["workflow_runs"]

def lowercase_						(     _snake_case		):
							SCREAMING_SNAKE_CASE__		: Tuple     =     get_daily_ci_runs(_snake_case		)
							SCREAMING_SNAKE_CASE__		: int     =     None
							for workflow_run in workflow_runs:
														if workflow_run["status"] == "completed":
																					SCREAMING_SNAKE_CASE__		: Union[str, Any]     =     workflow_run["""id"""]
																					break

							return workflow_run_id

def lowercase_						(     _snake_case     ,_snake_case     ,_snake_case		):
							SCREAMING_SNAKE_CASE__		: Dict     =     get_last_daily_ci_runs(_snake_case		)
							if workflow_run_id is not None:
														SCREAMING_SNAKE_CASE__		: Tuple     =     get_artifacts_links(worflow_run_id=_snake_case     ,token=_snake_case		)
														for artifact_name in artifact_names:
																					if artifact_name in artifacts_links:
																												SCREAMING_SNAKE_CASE__		: Tuple     =     artifacts_links[artifact_name]
																												download_artifact(
																												    artifact_name=_snake_case     ,artifact_url=_snake_case     ,output_dir=_snake_case     ,token=_snake_case		)

def lowercase_						(     _snake_case     ,_snake_case     ,_snake_case		):
							get_last_daily_ci_artifacts(_snake_case     ,_snake_case     ,_snake_case		)

							SCREAMING_SNAKE_CASE__		: List[str]     =     {}
							for artifact_name in artifact_names:
														SCREAMING_SNAKE_CASE__		: Optional[Any]     =     os.path.join(_snake_case     ,f'''{artifact_name}.zip'''		)
														if os.path.isfile(_snake_case		):
																					SCREAMING_SNAKE_CASE__		: List[Any]     =     {}
																					with zipfile.ZipFile(_snake_case		) as z:
																												for filename in z.namelist():
																																			if not os.path.isdir(_snake_case		):
																																										# read the file
																																										with z.open(_snake_case		) as f:
																																																	SCREAMING_SNAKE_CASE__		: List[Any]     =     f.read().decode("""UTF-8"""		)

							return results




