


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 						_snake_case    ( unittest.TestCase				):




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




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

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

       a		:Optional[int]									=			audio_classifier([audio] * 5   ,    candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']       )
       self.assertEqual(
           nested_simplify(_lowerCamelCase       )   ,    [
               [
                   {'''score''': 0.999, '''label''': '''Sound of a dog'''},
                   {'''score''': 0.001, '''label''': '''Sound of vaccum cleaner'''},
               ],
           ]
           * 5   ,    )
       a		:Optional[int]									=			audio_classifier(
           [audio] * 5   ,    candidate_labels=['''Sound of a dog''', '''Sound of vaccum cleaner''']   ,    batch_size=5       )
       self.assertEqual(
           nested_simplify(_lowerCamelCase       )   ,    [
               [
                   {'''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 			SCREAMING_SNAKE_CASE__							(						self       ):
       pass









snake_case							:       Any										=	{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

snake_case							:       Any										=	{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}
def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]					,    UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						list[bool]		):




      """simple docstring"""





      a		:Any									=			True
      a		:Any									=			[]

      for neighbour in graph[vert]:
            if not visited[neighbour]:
                  order += topology_sort(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)

      order.append(UpperCAmelCase_		)

      return order
def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]					,    UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						list[bool]		):




      """simple docstring"""





      a		:Optional[Any]									=			True
      a		:int									=			[vert]

      for neighbour in reversed_graph[vert]:
            if not visited[neighbour]:
                  component += find_components(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)

      return component






def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]		):




      """simple docstring"""





      a		:int									=			len(UpperCAmelCase_		) * [False]
      a		:dict[int, list[int]]									=			{vert: [] for vert in range(len(UpperCAmelCase_		)		)}

      for vert, neighbours in graph.items():
            for neighbour in neighbours:
                  reversed_graph[neighbour].append(UpperCAmelCase_		)

      a		:Optional[Any]									=			[]
      for i, was_visited in enumerate(UpperCAmelCase_		):
            if not was_visited:
                  order += topology_sort(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)

      a		:Tuple									=			[]
      a		:int									=			len(UpperCAmelCase_		) * [False]

      for i in range(len(UpperCAmelCase_		)		):
            a		:Union[str, Any]									=			order[len(UpperCAmelCase_		) - i - 1]
            if not visited[vert]:
                  a		:Union[str, Any]									=			find_components(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)
                  components_list.append(UpperCAmelCase_		)

      return components_list





