


'''simple docstring'''
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


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

UpperCAmelCase_ :     Dict								=      {
    'google/mobilenet_v1_1.0_224': 'https://huggingface.co/google/mobilenet_v1_1.0_224/resolve/main/config.json',
    'google/mobilenet_v1_0.75_192': 'https://huggingface.co/google/mobilenet_v1_0.75_192/resolve/main/config.json',
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
}

class 						_lowerCamelCase					(    snake_case_				):




 '''simple docstring'''
 __lowercase				:		int    							=						'''mobilenet_v1'''


 def __init__(      self      ,      __lowercase=3      ,      __lowercase=224      ,      __lowercase=1.0      ,      __lowercase=8      ,      __lowercase="relu6"      ,      __lowercase=True      ,      __lowercase=0.9_9_9      ,      __lowercase=0.0_2      ,      __lowercase=0.0_0_1      ,      **__lowercase      ,      ):

  """simple docstring"""







  super().__init__(**__lowercase						)

  if depth_multiplier <= 0:
   raise ValueError('depth_multiplier must be greater than zero.'						)

  __A  :		Any       =			num_channels
  __A  :		Any       =			image_size
  __A  :		int       =			depth_multiplier
  __A  :		int       =			min_depth
  __A  :		Union[str, Any]       =			hidden_act
  __A  :		Optional[Any]       =			tf_padding
  __A  :		Union[str, Any]       =			classifier_dropout_prob
  __A  :		Dict       =			initializer_range
  __A  :		str       =			layer_norm_eps


class 						_lowerCamelCase					(    snake_case_				):




 '''simple docstring'''
 __lowercase				:		Any    							=						version.parse('''1.11'''				)


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return OrderedDict([('pixel_values', {0: 'batch'})]						)


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  if self.task == "image-classification":
   return OrderedDict([('logits', {0: 'batch'})]						)
  else:
   return OrderedDict([('last_hidden_state', {0: 'batch'}), ('pooler_output', {0: 'batch'})]						)







 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  return 1E-4










'''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






