


'''simple docstring'''
from typing import TYPE_CHECKING

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


UpperCAmelCase_ :     Optional[int]								=      {'configuration_mra': ['MRA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MraConfig']}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase_ :     List[Any]								=      [
     'MRA_PRETRAINED_MODEL_ARCHIVE_LIST',
     'MraForMaskedLM',
     'MraForMultipleChoice',
     'MraForQuestionAnswering',
     'MraForSequenceClassification',
     'MraForTokenClassification',
     'MraLayer',
     'MraModel',
     'MraPreTrainedModel',
 ]


if TYPE_CHECKING:
 from .configuration_mra import MRA_PRETRAINED_CONFIG_ARCHIVE_MAP, MraConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_mra import (
      MRA_PRETRAINED_MODEL_ARCHIVE_LIST,
      MraForMaskedLM,
      MraForMultipleChoice,
      MraForQuestionAnswering,
      MraForSequenceClassification,
      MraForTokenClassification,
      MraLayer,
      MraModel,
      MraPreTrainedModel,
  )
else:
 import sys

 UpperCAmelCase_ :     Any								=      _LazyModule(__name__, globals()['__file__'], _import_structure)










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




 '''simple docstring'''


 @require_torch
 def  snake_case__   (      self						):

  """simple docstring"""







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

  """simple docstring"""







  pass


 @slow
 @require_torch
 def  snake_case__   (      self						):

  """simple docstring"""







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

  __A  :		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      ,      )
  __A  :		str       =			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						):

  """simple docstring"""







  pass






