






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 							_UpperCamelCase			(       self					)       ->    List[str]:
								snake_case_				=							pipeline(
								    task='zero-shot-audio-classification'       ,			model='hf-internal-testing/tiny-clap-htsat-unfused'					)
								snake_case_				=							load_dataset('ashraq/esc50'					)
								snake_case_				=							dataset['train']['audio'][-1]['array']
								snake_case_				=							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 							_UpperCamelCase			(       self					)       ->    Any:
								pass




	@slow
	@require_torch
	def 							_UpperCamelCase			(       self					)       ->    List[str]:
								snake_case_				=							pipeline(
								    task='zero-shot-audio-classification'       ,			model='laion/clap-htsat-unfused'       ,			)
								# This is an audio of a dog
								snake_case_				=							load_dataset('ashraq/esc50'					)
								snake_case_				=							dataset['train']['audio'][-1]['array']
								snake_case_				=							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'},
								    ]       ,			)

								snake_case_				=							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       ,			)
								snake_case_				=							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 							_UpperCamelCase			(       self					)       ->    Dict:
								pass













class  UpperCamelCase_      :



	'''simple docstring'''




	def __init__(       self       ,			a					)       ->    None:
								snake_case_				=							set_counts
								snake_case_				=							max(a					)
								snake_case_				=							len(a					)
								snake_case_				=							[1] * num_sets
								snake_case_				=							list(range(a					)					)




	def 							_UpperCamelCase			(       self       ,			a       ,			a					)       ->    bool:
								snake_case_				=							self.get_parent(a					)
								snake_case_				=							self.get_parent(a					)

								if src_parent == dst_parent:
															return False

								if self.ranks[dst_parent] >= self.ranks[src_parent]:
															self.set_counts[dst_parent] += self.set_counts[src_parent]
															snake_case_				=							0
															snake_case_				=							dst_parent
															if self.ranks[dst_parent] == self.ranks[src_parent]:
																						self.ranks[dst_parent] += 1
															snake_case_				=							self.set_counts[dst_parent]
								else:
															self.set_counts[src_parent] += self.set_counts[dst_parent]
															snake_case_				=							0
															snake_case_				=							src_parent
															snake_case_				=							self.set_counts[src_parent]

								snake_case_				=							max(self.max_set       ,			a					)
								return True






	def 							_UpperCamelCase			(       self       ,			a					)       ->    int:
								if self.parents[disj_set] == disj_set:
															return disj_set
								snake_case_				=							self.get_parent(self.parents[disj_set]					)
								return self.parents[disj_set]





