






"""simple docstring"""






from collections import OrderedDict
from typing import Mapping

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


UpperCAmelCase_   : Union[str, Any]   			= logging.get_logger(__name__)

UpperCAmelCase_   : Any   			= {
    'kssteven/ibert-roberta-base': 'https://huggingface.co/kssteven/ibert-roberta-base/resolve/main/config.json',
    'kssteven/ibert-roberta-large': 'https://huggingface.co/kssteven/ibert-roberta-large/resolve/main/config.json',
    'kssteven/ibert-roberta-large-mnli': (
        'https://huggingface.co/kssteven/ibert-roberta-large-mnli/resolve/main/config.json'
    ),
}




class 							lowerCAmelCase__				(			UpperCAmelCase__ ):






      '''simple docstring'''

      __UpperCamelCase	 =  "ibert"
      def __init__(						self     :  Union[str, Any]						,	lowercase_     :  int=30522						,	lowercase_     :  str=768						,	lowercase_     :  Union[str, Any]=12						,	lowercase_     :  Any=12						,	lowercase_     :  Optional[Any]=3072						,	lowercase_     :  int="gelu"						,	lowercase_     :  Optional[int]=0.1						,	lowercase_     :  Any=0.1						,	lowercase_     :  Dict=512						,	lowercase_     :  Any=2						,	lowercase_     :  str=0.02						,	lowercase_     :  Tuple=1e-12						,	lowercase_     :  List[Any]=1						,	lowercase_     :  Dict=0						,	lowercase_     :  Optional[int]=2						,	lowercase_     :  List[Any]="absolute"						,	lowercase_     :  int=False						,	lowercase_     :  str="none"						,	**lowercase_     :  Union[str, Any]						,	):




          '''simple docstring'''


          super().__init__(pad_token_id=lowercase_						,	bos_token_id=lowercase_						,	eos_token_id=lowercase_						,	**lowercase_)

          SCREAMING_SNAKE_CASE_      :  List[str]    						=		vocab_size
          SCREAMING_SNAKE_CASE_      :  Dict    						=		hidden_size
          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		num_hidden_layers
          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		num_attention_heads
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		hidden_act
          SCREAMING_SNAKE_CASE_      :  Tuple    						=		intermediate_size
          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		hidden_dropout_prob
          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		attention_probs_dropout_prob
          SCREAMING_SNAKE_CASE_      :  List[Any]    						=		max_position_embeddings
          SCREAMING_SNAKE_CASE_      :  Any    						=		type_vocab_size
          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		initializer_range
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		layer_norm_eps
          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		position_embedding_type
          SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		quant_mode
          SCREAMING_SNAKE_CASE_      :  List[str]    						=		force_dequant




class 							lowerCAmelCase__				(			UpperCAmelCase__ ):






      '''simple docstring'''

      @property
      def _SCREAMING_SNAKE_CASE (						self     :  List[Any]):




          '''simple docstring'''


          if self.task == "multiple-choice":
              SCREAMING_SNAKE_CASE_      :  str    						=		{0: '''batch''', 1: '''choice''', 2: '''sequence'''}
          else:
              SCREAMING_SNAKE_CASE_      :  List[str]    						=		{0: '''batch''', 1: '''sequence'''}
          return OrderedDict(
              [
                  ('''input_ids''', dynamic_axis),
                  ('''attention_mask''', dynamic_axis),
              ])







"""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      ):





     '''simple docstring'''



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





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

         _UpperCAmelCase							:  List[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       ,	)
         _UpperCAmelCase							:  Tuple											=    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  __lowerCAmelCase	(					self		)							->					int:
         pass


