






"""simple docstring"""




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






						def 			lowerCamelCase__    (    self	)	->Optional[int]:







								'''simple docstring'''


								_a							=	torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0]	)
								_a							=	get_activation("gelu"	)
								self.assertTrue(torch.allclose(gelu_python(a_	)     ,     torch_builtin(a_	)	)	)
								self.assertFalse(torch.allclose(gelu_python(a_	)     ,     gelu_new(a_	)	)	)






						def 			lowerCamelCase__    (    self	)	->List[Any]:







								'''simple docstring'''


								_a							=	torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0]	)
								_a							=	get_activation("gelu"	)
								_a							=	get_activation("gelu_10"	)

								_a							=	torch_builtin(a_	)
								_a							=	geluaa(a_	)

								_a							=	torch.where(y_gelu_aa < 10.0     ,     1     ,     0	)

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






						def 			lowerCamelCase__    (    self	)	->Optional[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(a_	):
										get_activation("bogus"	)
								with self.assertRaises(a_	):
										get_activation(a_	)






						def 			lowerCamelCase__    (    self	)	->int:







								'''simple docstring'''


								_a							=	get_activation("gelu"	)
								_a							=	1
								_a							=	get_activation("gelu"	)
								self.assertEqual(acta.a     ,     1	)
								with self.assertRaises(a_	):
										_a							=	acta.a










"""simple docstring"""




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCamelCase							       =    {"""configuration_fnet""": ["""FNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FNetConfig"""]}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCamelCase							       =    ["""FNetTokenizer"""]

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCamelCase							       =    ["""FNetTokenizerFast"""]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCamelCase							       =    [
         """FNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """FNetForMaskedLM""",
         """FNetForMultipleChoice""",
         """FNetForNextSentencePrediction""",
         """FNetForPreTraining""",
         """FNetForQuestionAnswering""",
         """FNetForSequenceClassification""",
         """FNetForTokenClassification""",
         """FNetLayer""",
         """FNetModel""",
         """FNetPreTrainedModel""",
     ]


if TYPE_CHECKING:
     from .configuration_fnet import FNET_PRETRAINED_CONFIG_ARCHIVE_MAP, FNetConfig

     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_fnet import FNetTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_fnet_fast import FNetTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_fnet import (
              FNET_PRETRAINED_MODEL_ARCHIVE_LIST,
              FNetForMaskedLM,
              FNetForMultipleChoice,
              FNetForNextSentencePrediction,
              FNetForPreTraining,
              FNetForQuestionAnswering,
              FNetForSequenceClassification,
              FNetForTokenClassification,
              FNetLayer,
              FNetModel,
              FNetPreTrainedModel,
          )


else:
     import sys

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


