




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

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

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

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







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_snake_case            = {
    "configuration_time_series_transformer": [
        "TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "TimeSeriesTransformerConfig",
    ],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _snake_case            = [
      "TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TimeSeriesTransformerForPrediction",
      "TimeSeriesTransformerModel",
      "TimeSeriesTransformerPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_time_series_transformer import (
      TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
      TimeSeriesTransformerConfig,
  )

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_time_series_transformer import (
        TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        TimeSeriesTransformerForPrediction,
        TimeSeriesTransformerModel,
        TimeSeriesTransformerPreTrainedModel,
    )

else:
  import sys

  _snake_case            = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)

