


'''simple docstring'''
import warnings

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


UpperCAmelCase_ :     str								=      logging.get_logger(__name__)

UpperCAmelCase_ :     List[Any]								=      {
    'xlnet-base-cased': 'https://huggingface.co/xlnet-base-cased/resolve/main/config.json',
    'xlnet-large-cased': 'https://huggingface.co/xlnet-large-cased/resolve/main/config.json',
}

class 						_lowerCamelCase					(    snake_case_				):




 '''simple docstring'''
 __lowercase				:		Any    							=						'''xlnet'''
 __lowercase				:		List[Any]    							=						['''mems''']
 __lowercase				:		Dict    							=						{
     '''n_token''': '''vocab_size''',  # Backward compatibility
     '''hidden_size''': '''d_model''',
     '''num_attention_heads''': '''n_head''',
     '''num_hidden_layers''': '''n_layer''',
 }


 def __init__(      self      ,      __lowercase=32_000      ,      __lowercase=1_024      ,      __lowercase=24      ,      __lowercase=16      ,      __lowercase=4_096      ,      __lowercase="gelu"      ,      __lowercase=True      ,      __lowercase="bi"      ,      __lowercase=0.0_2      ,      __lowercase=1E-12      ,      __lowercase=0.1      ,      __lowercase=512      ,      __lowercase=None      ,      __lowercase=True      ,      __lowercase=False      ,      __lowercase=False      ,      __lowercase=-1      ,      __lowercase=False      ,      __lowercase="last"      ,      __lowercase=True      ,      __lowercase="tanh"      ,      __lowercase=0.1      ,      __lowercase=5      ,      __lowercase=5      ,      __lowercase=5      ,      __lowercase=1      ,      __lowercase=2      ,      **__lowercase      ,      ):

  """simple docstring"""







  __A  :		Optional[int]       =			vocab_size
  __A  :		str       =			d_model
  __A  :		Any       =			n_layer
  __A  :		List[Any]       =			n_head
  if d_model % n_head != 0:
   raise ValueError(F"""'d_model % n_head' ({d_model % n_head}) should be equal to 0"""						)
  if "d_head" in kwargs:
   if kwargs["d_head"] != d_model // n_head:
    raise ValueError(
        F"""`d_head` ({kwargs['d_head']}) should be equal to `d_model // n_head` ({d_model // n_head})"""						)
  __A  :		Tuple       =			d_model // n_head
  __A  :		Optional[int]       =			ff_activation
  __A  :		str       =			d_inner
  __A  :		str       =			untie_r
  __A  :		Optional[int]       =			attn_type

  __A  :		Any       =			initializer_range
  __A  :		Union[str, Any]       =			layer_norm_eps

  __A  :		Any       =			dropout
  __A  :		Optional[int]       =			mem_len
  __A  :		str       =			reuse_len
  __A  :		str       =			bi_data
  __A  :		Optional[Any]       =			clamp_len
  __A  :		List[Any]       =			same_length

  __A  :		Union[str, Any]       =			summary_type
  __A  :		List[Any]       =			summary_use_proj
  __A  :		List[str]       =			summary_activation
  __A  :		Union[str, Any]       =			summary_last_dropout
  __A  :		Optional[Any]       =			start_n_top
  __A  :		Any       =			end_n_top

  __A  :		List[Any]       =			bos_token_id
  __A  :		int       =			pad_token_id
  __A  :		str       =			eos_token_id

  if "use_cache" in kwargs:
   warnings.warn(
       'The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`'
       ' instead.'      ,      __lowercase      ,      )
   __A  :		Any       =			kwargs['use_cache']

  __A  :		Dict       =			use_mems_eval
  __A  :		List[Any]       =			use_mems_train
  super().__init__(pad_token_id=__lowercase      ,      bos_token_id=__lowercase      ,      eos_token_id=__lowercase      ,      **__lowercase						)


 @property
 def  snake_case__   (      self						):

  """simple docstring"""







  logger.info(F"""The model {self.model_type} is one of the few models that has no sequence length limit."""						)
  return -1







 @max_position_embeddings.setter
 def  snake_case__   (      self      ,      __lowercase						):

  """simple docstring"""







  raise NotImplementedError(
      F"""The model {self.model_type} is one of the few models that has no sequence length limit."""						)










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






