

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

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

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









'''simple docstring'''

from ....utils import logging


A_       						=							logging.get_logger(__name__)





class 							_snake_case (       _a						):
   def __init__( self			:      Optional[Any]     ,SCREAMING_SNAKE_CASE__			:      Optional[int]     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]=None     ,SCREAMING_SNAKE_CASE__			:      Optional[int]=2_048							):
     SCREAMING_SNAKE_CASE:int						      =					config.__dict__
     SCREAMING_SNAKE_CASE:List[str]						      =					modal_hidden_size
     if num_labels:
       SCREAMING_SNAKE_CASE:str						      =					num_labels






