





from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowercase       :Optional[Any]       =  logging.get_logger(__name__)

__lowercase       :Dict       =  {
    "MIT/ast-finetuned-audioset-10-10-0.4593": (
        "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json"
    ),
}



class    _a     (				lowercase__							):






							"""simple docstring"""

							snake_case_							 =						"audio-spectrogram-transformer"

							def __init__(      self				:     str							,	a				:     Dict=7_68							,	a				:     List[str]=12							,	a				:     List[str]=12							,	a				:     Optional[int]=30_72							,	a				:     Dict="gelu"							,	a				:     str=0.0							,	a				:     int=0.0							,	a				:     int=0.02							,	a				:     Optional[int]=1E-12							,	a				:     Optional[int]=16							,	a				:     Tuple=True							,	a				:     List[str]=10							,	a				:     int=10							,	a				:     int=10_24							,	a				:     Optional[Any]=1_28							,	**a				:     List[str]							,	)	->List[Any]:
													super().__init__(**a    )

													SCREAMING_SNAKE_CASE__     :				Dict   =					hidden_size
													SCREAMING_SNAKE_CASE__     :				List[Any]   =					num_hidden_layers
													SCREAMING_SNAKE_CASE__     :				int   =					num_attention_heads
													SCREAMING_SNAKE_CASE__     :				Optional[int]   =					intermediate_size
													SCREAMING_SNAKE_CASE__     :				Any   =					hidden_act
													SCREAMING_SNAKE_CASE__     :				str   =					hidden_dropout_prob
													SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					attention_probs_dropout_prob
													SCREAMING_SNAKE_CASE__     :				List[Any]   =					initializer_range
													SCREAMING_SNAKE_CASE__     :				str   =					layer_norm_eps
													SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					patch_size
													SCREAMING_SNAKE_CASE__     :				Tuple   =					qkv_bias
													SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					frequency_stride
													SCREAMING_SNAKE_CASE__     :				Tuple   =					time_stride
													SCREAMING_SNAKE_CASE__     :				str   =					max_length
													SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					num_mel_bins






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






							"""simple docstring"""

							@require_torch
							def      A_  (      self				:     Dict    )	->str:
													SCREAMING_SNAKE_CASE__     :				Any   =					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__     :				Optional[int]   =					dataset["train"]["audio"][-1]["array"]
													SCREAMING_SNAKE_CASE__     :				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      A_  (      self				:     int    )	->Union[str, Any]:
													pass

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

													SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					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							,	)
													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(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				:     Optional[int]    )	->Union[str, Any]:
													pass