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







				'''simple docstring'''





				@require_torch
				def  snake_case__				(						self					:						Optional[Any]					)							->Any:


										'''simple docstring'''




										_UpperCamelCase			:			int   			=						pipeline(
										    task="zero-shot-audio-classification"       ,		model="hf-internal-testing/tiny-clap-htsat-unfused"					)
										_UpperCamelCase			:			List[Any]   			=						load_dataset("ashraq/esc50"					)
										_UpperCamelCase			:			Tuple   			=						dataset["train"]["audio"][-1]["array"]
										_UpperCamelCase			:			Optional[Any]   			=						audio_classifier(lowercase__       ,		candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]					)
										self.assertEqual(
										    nested_simplify(lowercase__					)       ,		[{"score": 0.5_0_1, "label": "Sound of a dog"}, {"score": 0.4_9_9, "label": "Sound of vaccum cleaner"}]       ,		)





				@unittest.skip("No models are available in TF"					)
				def  snake_case__				(						self					:						Optional[int]					)							->Union[str, Any]:


										'''simple docstring'''




										pass





				@slow
				@require_torch
				def  snake_case__				(						self					:						str					)							->Optional[Any]:


										'''simple docstring'''




										_UpperCamelCase			:			Union[str, Any]   			=						pipeline(
										    task="zero-shot-audio-classification"       ,		model="laion/clap-htsat-unfused"       ,		)
										# This is an audio of a dog
										_UpperCamelCase			:			Dict   			=						load_dataset("ashraq/esc50"					)
										_UpperCamelCase			:			int   			=						dataset["train"]["audio"][-1]["array"]
										_UpperCamelCase			:			Optional[Any]   			=						audio_classifier(lowercase__       ,		candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]					)

										self.assertEqual(
										    nested_simplify(lowercase__					)       ,		[
										        {"score": 0.9_9_9, "label": "Sound of a dog"},
										        {"score": 0.0_0_1, "label": "Sound of vaccum cleaner"},
										    ]       ,		)

										_UpperCamelCase			:			Optional[Any]   			=						audio_classifier([audio] * 5       ,		candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]					)
										self.assertEqual(
										    nested_simplify(lowercase__					)       ,		[
										        [
										            {"score": 0.9_9_9, "label": "Sound of a dog"},
										            {"score": 0.0_0_1, "label": "Sound of vaccum cleaner"},
										        ],
										    ]
										    * 5       ,		)
										_UpperCamelCase			:			Dict   			=						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_9_9, "label": "Sound of a dog"},
										            {"score": 0.0_0_1, "label": "Sound of vaccum cleaner"},
										        ],
										    ]
										    * 5       ,		)







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


										'''simple docstring'''




										pass



'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCAmelCase_	:		Union[str, Any]			=     {"""configuration_opt""": ["""OPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """OPTConfig"""]}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		Tuple			=     [
			    """OPT_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """OPTForCausalLM""",
			    """OPTModel""",
			    """OPTPreTrainedModel""",
			    """OPTForSequenceClassification""",
			    """OPTForQuestionAnswering""",
			]

try:
			if not is_tf_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		str			=     ["""TFOPTForCausalLM""", """TFOPTModel""", """TFOPTPreTrainedModel"""]

try:
			if not is_flax_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		List[Any]			=     [
			    """FlaxOPTForCausalLM""",
			    """FlaxOPTModel""",
			    """FlaxOPTPreTrainedModel""",
			]


if TYPE_CHECKING:
			from .configuration_opt import OPT_PRETRAINED_CONFIG_ARCHIVE_MAP, OPTConfig

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_opt import (
						    OPT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    OPTForCausalLM,
						    OPTForQuestionAnswering,
						    OPTForSequenceClassification,
						    OPTModel,
						    OPTPreTrainedModel,
						)

			try:
						if not is_tf_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tf_opt import TFOPTForCausalLM, TFOPTModel, TFOPTPreTrainedModel

			try:
						if not is_flax_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_flax_opt import FlaxOPTForCausalLM, FlaxOPTModel, FlaxOPTPreTrainedModel

else:
			import sys

			lowerCAmelCase_	:		Any			=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


