


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 				lowerCamelCase__(   self     :List[str]   )      ->					Optional[Any]:
												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(__snake_case    ,candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']   )
												self.assertEqual(
												    nested_simplify(__snake_case   )    ,[{'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 				lowerCamelCase__(   self     :Union[str, Any]   )      ->					List[str]:
												pass
					@slow
					@require_torch
					def 				lowerCamelCase__(   self     :Any   )      ->					Optional[Any]:
												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(__snake_case    ,candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']   )

												self.assertEqual(
												    nested_simplify(__snake_case   )    ,[
												        {'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(__snake_case   )    ,[
												        [
												            {'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(__snake_case   )    ,[
												        [
												            {'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 				lowerCamelCase__(   self     :List[str]   )      ->					Optional[int]:
												pass








from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


snake_case							: Optional[Any]      =   {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']}


try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						snake_case							: Optional[int]      =   [
						    '''FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''FocalNetForImageClassification''',
						    '''FocalNetForMaskedImageModeling''',
						    '''FocalNetBackbone''',
						    '''FocalNetModel''',
						    '''FocalNetPreTrainedModel''',
						]

if TYPE_CHECKING:
						from .configuration_focalnet import FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FocalNetConfig

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_focalnet import (
												    FOCALNET_PRETRAINED_MODEL_ARCHIVE_LIST,
												    FocalNetBackbone,
												    FocalNetForImageClassification,
												    FocalNetForMaskedImageModeling,
												    FocalNetModel,
												    FocalNetPreTrainedModel,
												)

else:
						import sys

						snake_case							: Union[str, Any]      =   _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




