






from typing import TYPE_CHECKING

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


__lowerCamelCase      :    Union[str, Any]   		=   {
    """configuration_falcon""": ["""FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FalconConfig"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase      :    str   		=   [
	    """FALCON_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """FalconForCausalLM""",
	    """FalconModel""",
	    """FalconPreTrainedModel""",
	    """FalconForSequenceClassification""",
	    """FalconForTokenClassification""",
	    """FalconForQuestionAnswering""",
	]


if TYPE_CHECKING:
	from .configuration_falcon import FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP, FalconConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_falcon import (
		    FALCON_PRETRAINED_MODEL_ARCHIVE_LIST,
		    FalconForCausalLM,
		    FalconForQuestionAnswering,
		    FalconForSequenceClassification,
		    FalconForTokenClassification,
		    FalconModel,
		    FalconPreTrainedModel,
		)


else:
	import sys

	__lowerCamelCase      :    str   		=   _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)











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  _lowercase  (      self  :						Tuple ):
						snake_case__				:   List[str]     =						torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0] )
						snake_case__				:   Tuple     =						get_activation("gelu" )
						self.assertTrue(torch.allclose(gelu_python(__A )							,	torch_builtin(__A ) ) )
						self.assertFalse(torch.allclose(gelu_python(__A )							,	gelu_new(__A ) ) )



					def  _lowercase  (      self  :						Dict ):
						snake_case__				:   str     =						torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0] )
						snake_case__				:   Union[str, Any]     =						get_activation("gelu" )
						snake_case__				:   int     =						get_activation("gelu_10" )

						snake_case__				:   Optional[int]     =						torch_builtin(__A )
						snake_case__				:   Dict     =						geluaa(__A )

						snake_case__				:   Optional[Any]     =						torch.where(y_gelu_aa < 1_0.0							,	1							,	0 )

						self.assertTrue(torch.max(__A ).item() == 1_0.0 )
						self.assertTrue(torch.allclose(y_gelu * clipped_mask							,	y_gelu_aa * clipped_mask ) )



					def  _lowercase  (      self  :						str ):
						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  _lowercase  (      self  :						List[str] ):
						snake_case__				:   List[str]     =						get_activation("gelu" )
						snake_case__				:   Any     =						1
						snake_case__				:   Union[str, Any]     =						get_activation("gelu" )
						self.assertEqual(acta.a							,	1 )
						with self.assertRaises(__A ):
							snake_case__				:   int     =						acta.a



