



import functools
import operator

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


snake_case__					:     Tuple    		=   logging.get_logger(__name__)

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   _A   ( _lowercase	):


						'''simple docstring'''





						_snake_case			:     List[Any]      							=      """unispeech"""



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






							'''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     _snake_case	(	self	:							List[str]	):






							'''simple docstring'''



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








from __future__ import annotations

from typing import Any

class   _A   :


						'''simple docstring'''





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






							'''simple docstring'''



							__lowercase		       =			num_of_nodes
							__lowercase		       =			[]
							__lowercase		       =			{}



						def     _snake_case	(	self	:							Dict							,      lowerCamelCase	:							int							,      lowerCamelCase	:							int							,      lowerCamelCase	:							int	):






							'''simple docstring'''



							self.m_edges.append([u_node, v_node, weight]	)



						def     _snake_case	(	self	:							List[Any]							,      lowerCamelCase	:							int	):






							'''simple docstring'''



							if self.m_component[u_node] == u_node:
								return u_node
							return self.find_component(self.m_component[u_node]	)



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






							'''simple docstring'''



							if self.m_component[u_node] != u_node:
								for k in self.m_component:
									__lowercase		       =			self.find_component(lowerCamelCase	)



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






							'''simple docstring'''



							if component_size[u_node] <= component_size[v_node]:
								__lowercase		       =			v_node
								component_size[v_node] += component_size[u_node]
								self.set_component(lowerCamelCase	)

							elif component_size[u_node] >= component_size[v_node]:
								__lowercase		       =			self.find_component(lowerCamelCase	)
								component_size[u_node] += component_size[v_node]
								self.set_component(lowerCamelCase	)



						def     _snake_case	(	self	:							Any	):






							'''simple docstring'''



							__lowercase		       =			[]
							__lowercase		       =			0

							__lowercase		       =			[-1] * self.m_num_of_nodes

							# A list of components (initialized to all of the nodes)
							for node in range(self.m_num_of_nodes	):
								self.m_component.update({node: node}	)
								component_size.append(1	)

							__lowercase		       =			self.m_num_of_nodes

							while num_of_components > 1:
								for edge in self.m_edges:
									__lowercase       ,    __lowercase       ,    __lowercase		       =			edge

									__lowercase		       =			self.m_component[u]
									__lowercase		       =			self.m_component[v]

									if u_component != v_component:

										for component in (u_component, v_component):
											if (
											    minimum_weight_edge[component] == -1
											    or minimum_weight_edge[component][2] > w
											):
												__lowercase		       =			[u, v, w]

								for edge in minimum_weight_edge:
									if isinstance(lowerCamelCase							,      lowerCamelCase	):
										__lowercase       ,    __lowercase       ,    __lowercase		       =			edge

										__lowercase		       =			self.m_component[u]
										__lowercase		       =			self.m_component[v]

										if u_component != v_component:
											mst_weight += w
											self.union(lowerCamelCase							,      lowerCamelCase							,      lowerCamelCase	)
											print(f"""Added edge [{u} - {v}]\nAdded weight: {w}\n"""	)
											num_of_components -= 1

								__lowercase		       =			[-1] * self.m_num_of_nodes
							print(f"""The total weight of the minimal spanning tree is: {mst_weight}"""	)



def    snake_case_				(    ):
	pass


if __name__ == "__main__":
	import doctest

	doctest.testmod()



