




'''simple docstring'''
from __future__ import annotations

from typing import Any
class   __UpperCAmelCase				:



					'''simple docstring'''





					def __init__(	self     :						int      ,       _lowercase     :						int)    ->							None:
								A_									= num_of_nodes
								A_									= []
								A_									= {}



					def     __snake_case						(	self     :						str      ,       _lowercase     :						int      ,       _lowercase     :						int      ,       _lowercase     :						int)    ->							None:
								self.m_edges.append([u_node, v_node, weight])



					def     __snake_case						(	self     :						Union[str, Any]      ,       _lowercase     :						int)    ->							int:

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



					def     __snake_case						(	self     :						Optional[int]      ,       _lowercase     :						int)    ->							None:

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



					def     __snake_case						(	self     :						List[Any]      ,       _lowercase     :						list[int]      ,       _lowercase     :						int      ,       _lowercase     :						int)    ->							None:

								if component_size[u_node] <= component_size[v_node]:
											A_									= v_node
											component_size[v_node] += component_size[u_node]
											self.set_component(_lowercase)

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



					def     __snake_case						(	self     :						int)    ->							None:
								A_									= []
								A_									= 0

								A_									= [-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)

								A_									= self.m_num_of_nodes

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

														A_									= self.m_component[u]
														A_									= 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
																				):
																							A_									= [u, v, w]

											for edge in minimum_weight_edge:
														if isinstance(_lowercase      ,       _lowercase):
																	A_		, A_		, A_									= edge

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

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

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





def 			lowerCamelCase(							)		->		None:
			pass


if __name__ == "__main__":
							import doctest

							doctest.testmod()










'''simple docstring'''
import unittest

from datasets import load_dataset

from transformers.pipelines import pipeline
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow
@is_pipeline_test
@require_torch
class   __UpperCAmelCase				(     unittest.TestCase				):



					'''simple docstring'''





					@require_torch
					def     __snake_case						(	self     :						str)    ->							Optional[int]:
								A_									= pipeline(
								    task='zero-shot-audio-classification'      ,       model='hf-internal-testing/tiny-clap-htsat-unfused')
								A_									= load_dataset('ashraq/esc50')
								A_									= dataset['train']['audio'][-1]['array']
								A_									= audio_classifier(_lowercase      ,       candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner'])
								self.assertEqual(
								    nested_simplify(_lowercase)      ,       [{'score': 0.5_01, 'label': 'Sound of a dog'}, {'score': 0.4_99, 'label': 'Sound of vaccum cleaner'}]      ,       )



					@unittest.skip('No models are available in TF')
					def     __snake_case						(	self     :						Tuple)    ->							str:
								pass



					@slow
					@require_torch
					def     __snake_case						(	self     :						Optional[Any])    ->							Tuple:
								A_									= pipeline(
								    task='zero-shot-audio-classification'      ,       model='laion/clap-htsat-unfused'      ,       )
								# This is an audio of a dog
								A_									= load_dataset('ashraq/esc50')
								A_									= dataset['train']['audio'][-1]['array']
								A_									= audio_classifier(_lowercase      ,       candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner'])

								self.assertEqual(
								    nested_simplify(_lowercase)      ,       [
								        {'score': 0.9_99, 'label': 'Sound of a dog'},
								        {'score': 0.0_01, 'label': 'Sound of vaccum cleaner'},
								    ]      ,       )

								A_									= audio_classifier([audio] * 5      ,       candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner'])
								self.assertEqual(
								    nested_simplify(_lowercase)      ,       [
								        [
								            {'score': 0.9_99, 'label': 'Sound of a dog'},
								            {'score': 0.0_01, 'label': 'Sound of vaccum cleaner'},
								        ],
								    ]
								    * 5      ,       )
								A_									= audio_classifier(
								    [audio] * 5      ,       candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']      ,       batch_size=5)
								self.assertEqual(
								    nested_simplify(_lowercase)      ,       [
								        [
								            {'score': 0.9_99, 'label': 'Sound of a dog'},
								            {'score': 0.0_01, 'label': 'Sound of vaccum cleaner'},
								        ],
								    ]
								    * 5      ,       )



					@unittest.skip('No models are available in TF')
					def     __snake_case						(	self     :						List[str])    ->							str:
								pass




