






import functools
import operator

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


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

A__			:    List[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      ( A__			):

				"""simple docstring"""




				lowercase__       							= """unispeech-sat"""




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

								'''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__     				=    vocab_size
								lowercase__     				=    num_clusters
								lowercase__     				=    do_stable_layer_norm
								lowercase__     				=    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
								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

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

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




				@property
				def        lowercase__     (  self		:					List[str]						):

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







from __future__ import annotations

from collections import deque
from collections.abc import Iterator
from dataclasses import dataclass
@dataclass
class    _UpperCAmelCase      :

				"""simple docstring"""




				lowercase__       							= 42
				lowercase__       							= 42



class    _UpperCAmelCase      :

				"""simple docstring"""




				def __init__(  self		:					str,						lowerCamelCase		:					int						):

								'''simple docstring'''
								lowercase__     				=    [[] for _ in range(lowerCamelCase						)]
								lowercase__     				=    size




				def __getitem__(  self		:					Optional[Any],						lowerCamelCase		:					int						):

								'''simple docstring'''
								return iter(self._graph[vertex]						)




				@property
				def        lowercase__     (  self		:					str						):

								'''simple docstring'''
								return self._size




				def        lowercase__     (  self		:					Union[str, Any],						lowerCamelCase		:					int,						lowerCamelCase		:					int,						lowerCamelCase		:					int						):

								'''simple docstring'''
								if weight not in (0, 1):
												raise ValueError('''Edge weight must be either 0 or 1.'''						)

								if to_vertex < 0 or to_vertex >= self.size:
												raise ValueError('''Vertex indexes must be in [0; size).'''						)

								self._graph[from_vertex].append(Edge(lowerCamelCase,						lowerCamelCase						)						)




				def        lowercase__     (  self		:					Optional[int],						lowerCamelCase		:					int,						lowerCamelCase		:					int						):

								'''simple docstring'''
								lowercase__     				=    deque([start_vertex]						)
								lowercase__     				=    [None] * self.size
								lowercase__     				=    0

								while queue:
												lowercase__     				=    queue.popleft()
												lowercase__     				=    distances[current_vertex]
												if current_distance is None:
																continue

												for edge in self[current_vertex]:
																lowercase__     				=    current_distance + edge.weight
																lowercase__     				=    distances[edge.destination_vertex]
																if (
																    isinstance(lowerCamelCase,						lowerCamelCase						)
																    and new_distance >= dest_vertex_distance
																):
																				continue
																lowercase__     				=    new_distance
																if edge.weight == 0:
																				queue.appendleft(edge.destination_vertex						)
																else:
																				queue.append(edge.destination_vertex						)

								if distances[finish_vertex] is None:
												raise ValueError('''No path from start_vertex to finish_vertex.'''						)

								return distances[finish_vertex]


if __name__ == "__main__":
							import doctest

							doctest.testmod()




