





import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
      import torch

      from transformers.activations import gelu_new, gelu_python, get_activation



@require_torch
class        _lowerCAmelCase    (			unittest.TestCase							):


  '''simple docstring'''







  def UpperCamelCase_ (      self      :					List[str]							):


    '''simple docstring'''





    _snake_case   :				List[Any]														=	torch.tensor([-1_00, -1, -0.1, 0, 0.1, 1.0, 1_00]							)
    _snake_case   :				Dict														=	get_activation('gelu'							)
    self.assertTrue(torch.allclose(gelu_python(UpperCamelCase							)      ,				torch_builtin(UpperCamelCase							)							)							)
    self.assertFalse(torch.allclose(gelu_python(UpperCamelCase							)      ,				gelu_new(UpperCamelCase							)							)							)







  def UpperCamelCase_ (      self      :					List[str]							):


    '''simple docstring'''





    _snake_case   :				str														=	torch.tensor([-1_00, -1, -0.1, 0, 0.1, 1.0, 1_00]							)
    _snake_case   :				List[Any]														=	get_activation('gelu'							)
    _snake_case   :				Any														=	get_activation('gelu_10'							)

    _snake_case   :				Optional[int]														=	torch_builtin(UpperCamelCase							)
    _snake_case   :				List[Any]														=	geluaa(UpperCamelCase							)

    _snake_case   :				Dict														=	torch.where(y_gelu_aa < 10.0      ,				1      ,				0							)

    self.assertTrue(torch.max(UpperCamelCase							).item() == 10.0							)
    self.assertTrue(torch.allclose(y_gelu * clipped_mask      ,				y_gelu_aa * clipped_mask							)							)







  def UpperCamelCase_ (      self      :					Tuple							):


    '''simple docstring'''





    get_activation('gelu'							)
    get_activation('gelu_10'							)
    get_activation('gelu_fast'							)
    get_activation('gelu_new'							)
    get_activation('gelu_python'							)
    get_activation('gelu_pytorch_tanh'							)
    get_activation('linear'							)
    get_activation('mish'							)
    get_activation('quick_gelu'							)
    get_activation('relu'							)
    get_activation('sigmoid'							)
    get_activation('silu'							)
    get_activation('swish'							)
    get_activation('tanh'							)
    with self.assertRaises(UpperCamelCase							):
      get_activation('bogus'							)
    with self.assertRaises(UpperCamelCase							):
      get_activation(UpperCamelCase							)







  def UpperCamelCase_ (      self      :					Tuple							):


    '''simple docstring'''





    _snake_case   :				Any														=	get_activation('gelu'							)
    _snake_case   :				Optional[Any]														=	1
    _snake_case   :				Optional[int]														=	get_activation('gelu'							)
    self.assertEqual(acta.a      ,				1							)
    with self.assertRaises(UpperCamelCase							):
      _snake_case   :				int														=	acta.a











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


lowerCAmelCase_						   =    logging.get_logger(__name__)

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



class        _lowerCAmelCase    (			UpperCAmelCase_							):


  '''simple docstring'''
  a_							:       Tuple      					="""audio-spectrogram-transformer"""







  def __init__(      self      :					List[Any]      ,				UpperCamelCase      :					Union[str, Any]=7_68      ,				UpperCamelCase      :					int=12      ,				UpperCamelCase      :					str=12      ,				UpperCamelCase      :					Tuple=30_72      ,				UpperCamelCase      :					Optional[Any]="gelu"      ,				UpperCamelCase      :					Any=0.0      ,				UpperCamelCase      :					Dict=0.0      ,				UpperCamelCase      :					List[Any]=0.02      ,				UpperCamelCase      :					Dict=1e-1_2      ,				UpperCamelCase      :					str=16      ,				UpperCamelCase      :					List[Any]=True      ,				UpperCamelCase      :					Any=10      ,				UpperCamelCase      :					Optional[int]=10      ,				UpperCamelCase      :					int=10_24      ,				UpperCamelCase      :					Optional[Any]=1_28      ,				**UpperCamelCase      :					Optional[Any]      ,				):


    '''simple docstring'''





    super().__init__(**UpperCamelCase							)

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




