

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     ):





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





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

         lowercase__    :   str      =       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						,   )
         lowercase__    :   Optional[int]      =       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       snake_case_				(      self):
         pass




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


snake_case_			  = {
    '''configuration_instructblip''': [
        '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''InstructBlipConfig''',
        '''InstructBlipQFormerConfig''',
        '''InstructBlipVisionConfig''',
    ],
    '''processing_instructblip''': ['''InstructBlipProcessor'''],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       snake_case_			  = [
           '''INSTRUCTBLIP_PRETRAINED_MODEL_ARCHIVE_LIST''',
           '''InstructBlipQFormerModel''',
           '''InstructBlipPreTrainedModel''',
           '''InstructBlipForConditionalGeneration''',
           '''InstructBlipVisionModel''',
       ]

if TYPE_CHECKING:
       from .configuration_instructblip import (
           INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
           InstructBlipConfig,
           InstructBlipQFormerConfig,
           InstructBlipVisionConfig,
       )
       from .processing_instructblip import InstructBlipProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_instructblip import (
                  INSTRUCTBLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
                  InstructBlipForConditionalGeneration,
                  InstructBlipPreTrainedModel,
                  InstructBlipQFormerModel,
                  InstructBlipVisionModel,
              )

else:
       import sys

       snake_case_			  = _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)

