





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







 '''simple docstring'''

 def 							SCREAMING_SNAKE_CASE_					(self				:   Union[str, Any])       ->Tuple:



   '''simple docstring'''



   lowerCamelCase__:      str			  =torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100])
   lowerCamelCase__:      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 							SCREAMING_SNAKE_CASE_					(self				:   str)       ->str:



   '''simple docstring'''



   lowerCamelCase__:      List[str]			  =torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100])
   lowerCamelCase__:      str			  =get_activation("gelu")
   lowerCamelCase__:      Union[str, Any]			  =get_activation("gelu_10")

   lowerCamelCase__:      Dict			  =torch_builtin(UpperCAmelCase_)
   lowerCamelCase__:      Any			  =geluaa(UpperCAmelCase_)

   lowerCamelCase__:      Union[str, Any]			  =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 							SCREAMING_SNAKE_CASE_					(self				:   str)       ->Union[str, Any]:



   '''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 							SCREAMING_SNAKE_CASE_					(self				:   List[Any])       ->Tuple:



   '''simple docstring'''



   lowerCamelCase__:      Dict			  =get_activation("gelu")
   lowerCamelCase__:      str			  =1
   lowerCamelCase__:      Union[str, Any]			  =get_activation("gelu")
   self.assertEqual(acta.a       , 1)
   with self.assertRaises(UpperCAmelCase_):
     lowerCamelCase__:      Union[str, Any]			  =acta.a








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__A									=				{"configuration_ibert": ["IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "IBertConfig", "IBertOnnxConfig"]}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     __A									=				[
         "IBERT_PRETRAINED_MODEL_ARCHIVE_LIST",
         "IBertForMaskedLM",
         "IBertForMultipleChoice",
         "IBertForQuestionAnswering",
         "IBertForSequenceClassification",
         "IBertForTokenClassification",
         "IBertModel",
         "IBertPreTrainedModel",
     ]

if TYPE_CHECKING:
     from .configuration_ibert import IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, IBertConfig, IBertOnnxConfig

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_ibert import (
              IBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
              IBertForMaskedLM,
              IBertForMultipleChoice,
              IBertForQuestionAnswering,
              IBertForSequenceClassification,
              IBertForTokenClassification,
              IBertModel,
              IBertPreTrainedModel,
          )

else:
     import sys

     __A									=				_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)

