





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_snake_case    :       List[str]		       =    {'configuration_yolos': ['YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'YolosConfig', 'YolosOnnxConfig']}

try:
     if not is_vision_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _snake_case    :       List[Any]		       =    ['YolosFeatureExtractor']
     _snake_case    :       Optional[Any]		       =    ['YolosImageProcessor']

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _snake_case    :       str		       =    [
         'YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST',
         'YolosForObjectDetection',
         'YolosModel',
         'YolosPreTrainedModel',
     ]


if TYPE_CHECKING:
     from .configuration_yolos import YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP, YolosConfig, YolosOnnxConfig

     try:
          if not is_vision_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .feature_extraction_yolos import YolosFeatureExtractor
          from .image_processing_yolos import YolosImageProcessor

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_yolos import (
              YOLOS_PRETRAINED_MODEL_ARCHIVE_LIST,
              YolosForObjectDetection,
              YolosModel,
              YolosPreTrainedModel,
          )


else:
     import sys

     _snake_case    :       List[str]		       =    _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)







'''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     __snake_case						(	self     :						str)    ->							Optional[int]:
								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(_lowercase      ,       candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner'])
								self.assertEqual(
								    nested_simplify(_lowercase)      ,       [{'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     __snake_case						(	self     :						Tuple)    ->							str:
								pass



					@slow
					@require_torch
					def     __snake_case						(	self     :						Optional[Any])    ->							Tuple:
								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(_lowercase      ,       candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner'])

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




