


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




	@require_torch
	def 				__UpperCAmelCase							(       self							):

						'''simple docstring'''





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

						'''simple docstring'''





						pass




	@slow
	@require_torch
	def 				__UpperCAmelCase							(       self							):

						'''simple docstring'''





						__a      :	List[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      :	Tuple    =  dataset['train']['audio'][-1]['array']
						__a      :	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'},
						    ]						,    )

						__a      :	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						,    )
						__a      :	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 				__UpperCAmelCase							(       self							):

						'''simple docstring'''





						pass







'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__lowercase     :						Tuple	=     {
    'configuration_distilbert': [
        'DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'DistilBertConfig',
        'DistilBertOnnxConfig',
    ],
    'tokenization_distilbert': ['DistilBertTokenizer'],
}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase     :						str	=     ['DistilBertTokenizerFast']

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase     :						Any	=     [
	    'DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'DistilBertForMaskedLM',
	    'DistilBertForMultipleChoice',
	    'DistilBertForQuestionAnswering',
	    'DistilBertForSequenceClassification',
	    'DistilBertForTokenClassification',
	    'DistilBertModel',
	    'DistilBertPreTrainedModel',
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase     :						List[str]	=     [
	    'TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'TFDistilBertForMaskedLM',
	    'TFDistilBertForMultipleChoice',
	    'TFDistilBertForQuestionAnswering',
	    'TFDistilBertForSequenceClassification',
	    'TFDistilBertForTokenClassification',
	    'TFDistilBertMainLayer',
	    'TFDistilBertModel',
	    'TFDistilBertPreTrainedModel',
	]

try:
	if not is_flax_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowercase     :						List[str]	=     [
	    'FlaxDistilBertForMaskedLM',
	    'FlaxDistilBertForMultipleChoice',
	    'FlaxDistilBertForQuestionAnswering',
	    'FlaxDistilBertForSequenceClassification',
	    'FlaxDistilBertForTokenClassification',
	    'FlaxDistilBertModel',
	    'FlaxDistilBertPreTrainedModel',
	]


if TYPE_CHECKING:
	from .configuration_distilbert import (
	    DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    DistilBertConfig,
	    DistilBertOnnxConfig,
	)
	from .tokenization_distilbert import DistilBertTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_distilbert_fast import DistilBertTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_distilbert import (
		    DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    DistilBertForMaskedLM,
		    DistilBertForMultipleChoice,
		    DistilBertForQuestionAnswering,
		    DistilBertForSequenceClassification,
		    DistilBertForTokenClassification,
		    DistilBertModel,
		    DistilBertPreTrainedModel,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_distilbert import (
		    TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFDistilBertForMaskedLM,
		    TFDistilBertForMultipleChoice,
		    TFDistilBertForQuestionAnswering,
		    TFDistilBertForSequenceClassification,
		    TFDistilBertForTokenClassification,
		    TFDistilBertMainLayer,
		    TFDistilBertModel,
		    TFDistilBertPreTrainedModel,
		)

	try:
		if not is_flax_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_flax_distilbert import (
		    FlaxDistilBertForMaskedLM,
		    FlaxDistilBertForMultipleChoice,
		    FlaxDistilBertForQuestionAnswering,
		    FlaxDistilBertForSequenceClassification,
		    FlaxDistilBertForTokenClassification,
		    FlaxDistilBertModel,
		    FlaxDistilBertPreTrainedModel,
		)

else:
	import sys

	__lowercase     :						int	=     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)



