



"""simple docstring"""
import heapq as hq
import math
from collections.abc import Iterator
class 							_UpperCAmelCase							:





     '''simple docstring'''



     def __init__(					self       ,	A		)							->					Optional[int]:
         _UpperCAmelCase							:  Optional[int]											=    str(id_		)
         _UpperCAmelCase							:  Optional[int]											=    None
         _UpperCAmelCase							:  List[str]											=    None
         _UpperCAmelCase							:  Any											=    []
         _UpperCAmelCase							:  Optional[Any]											=    {}  # {vertex:distance}





     def __lt__(					self       ,	A		)							->					List[Any]:
         return self.key < other.key





     def __repr__(					self		)							->					int:
         return self.id





     def  __lowerCAmelCase	(					self       ,	A		)							->					List[str]:
         self.neighbors.append(A		)





     def  __lowerCAmelCase	(					self       ,	A       ,	A		)							->					Any:
         _UpperCAmelCase							:  Dict											=    weight





def  lowerCamelCase_						(UpperCamelCase__		:		List[str]     ,       UpperCamelCase__		:		Union[str, Any]     ,       UpperCamelCase__		:		int     ,       UpperCamelCase__		:		str							):
    # add the neighbors:
    graph[a - 1].add_neighbor(graph[b - 1]							)
    graph[b - 1].add_neighbor(graph[a - 1]							)
    # add the edges:
    graph[a - 1].add_edge(graph[b - 1]     ,       UpperCamelCase__							)
    graph[b - 1].add_edge(graph[a - 1]     ,       UpperCamelCase__							)





def  lowerCamelCase_						(UpperCamelCase__		:		list     ,       UpperCamelCase__		:		Vertex							):
    _UpperCAmelCase							:  str											=    []
    for u in graph:
        _UpperCAmelCase							:  Optional[int]											=    math.inf
        _UpperCAmelCase							:  int											=    None
    _UpperCAmelCase							:  str											=    0
    _UpperCAmelCase							:  Optional[Any]											=    graph[:]
    while q:
        _UpperCAmelCase							:  int											=    min(UpperCamelCase__							)
        q.remove(UpperCamelCase__							)
        for v in u.neighbors:
            if (v in q) and (u.edges[v.id] < v.key):
                _UpperCAmelCase							:  Optional[Any]											=    u
                _UpperCAmelCase							:  str											=    u.edges[v.id]
    for i in range(1     ,       len(UpperCamelCase__							)							):
        a.append((int(graph[i].id							) + 1, int(graph[i].pi.id							) + 1)							)
    return a





def  lowerCamelCase_						(UpperCamelCase__		:		list     ,       UpperCamelCase__		:		Vertex							):
    for u in graph:
        _UpperCAmelCase							:  Any											=    math.inf
        _UpperCAmelCase							:  List[str]											=    None
    _UpperCAmelCase							:  Dict											=    0

    _UpperCAmelCase							:  List[str]											=    list(UpperCamelCase__							)
    hq.heapify(UpperCamelCase__							)

    while h:
        _UpperCAmelCase							:  Union[str, Any]											=    hq.heappop(UpperCamelCase__							)
        for v in u.neighbors:
            if (v in h) and (u.edges[v.id] < v.key):
                _UpperCAmelCase							:  int											=    u
                _UpperCAmelCase							:  str											=    u.edges[v.id]
                hq.heapify(UpperCamelCase__							)

    for i in range(1     ,       len(UpperCamelCase__							)							):
        yield (int(graph[i].id							) + 1, int(graph[i].pi.id							) + 1)





def  lowerCamelCase_						():
    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  __lowerCAmelCase	(					self		)							->					Any:
         _UpperCAmelCase							:  str											=    pipeline(
             task='''zero-shot-audio-classification'''       ,	model='''hf-internal-testing/tiny-clap-htsat-unfused'''		)
         _UpperCAmelCase							:  List[Any]											=    load_dataset('''ashraq/esc50'''		)
         _UpperCAmelCase							:  Optional[int]											=    dataset['''train''']['''audio'''][-1]['''array''']
         _UpperCAmelCase							:  str											=    audio_classifier(A       ,	candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']		)
         self.assertEqual(
             nested_simplify(A		)       ,	[{'''score''': 0.501, '''label''': '''Sound of a dog'''}, {'''score''': 0.499, '''label''': '''Sound of vaccum cleaner'''}]       ,	)





     @unittest.skip('''No models are available in TF'''		)
     def  __lowerCAmelCase	(					self		)							->					Union[str, Any]:
         pass





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

         self.assertEqual(
             nested_simplify(A		)       ,	[
                 {'''score''': 0.999, '''label''': '''Sound of a dog'''},
                 {'''score''': 0.001, '''label''': '''Sound of vaccum cleaner'''},
             ]       ,	)

         _UpperCAmelCase							:  List[Any]											=    audio_classifier([audio] * 5       ,	candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']		)
         self.assertEqual(
             nested_simplify(A		)       ,	[
                 [
                     {'''score''': 0.999, '''label''': '''Sound of a dog'''},
                     {'''score''': 0.001, '''label''': '''Sound of vaccum cleaner'''},
                 ],
             ]
             * 5       ,	)
         _UpperCAmelCase							:  Tuple											=    audio_classifier(
             [audio] * 5       ,	candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']       ,	batch_size=5		)
         self.assertEqual(
             nested_simplify(A		)       ,	[
                 [
                     {'''score''': 0.999, '''label''': '''Sound of a dog'''},
                     {'''score''': 0.001, '''label''': '''Sound of vaccum cleaner'''},
                 ],
             ]
             * 5       ,	)





     @unittest.skip('''No models are available in TF'''		)
     def  __lowerCAmelCase	(					self		)							->					int:
         pass


