


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




				def 					a__(		self      :			List[Any]				)->					Optional[int]:

										"""simple docstring"""




										UpperCAmelCase					    =     torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]				)
										UpperCAmelCase					    =     get_activation('''gelu'''				)
										self.assertTrue(torch.allclose(gelu_python(lowerCAmelCase				)				,   torch_builtin(lowerCAmelCase				)				)				)
										self.assertFalse(torch.allclose(gelu_python(lowerCAmelCase				)				,   gelu_new(lowerCAmelCase				)				)				)




				def 					a__(		self      :			Optional[int]				)->					str:

										"""simple docstring"""




										UpperCAmelCase					    =     torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]				)
										UpperCAmelCase					    =     get_activation('''gelu'''				)
										UpperCAmelCase					    =     get_activation('''gelu_10'''				)

										UpperCAmelCase					    =     torch_builtin(lowerCAmelCase				)
										UpperCAmelCase					    =     geluaa(lowerCAmelCase				)

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

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




				def 					a__(		self      :			Optional[Any]				)->					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(lowerCAmelCase				):
																get_activation('''bogus'''				)
										with self.assertRaises(lowerCAmelCase				):
																get_activation(lowerCAmelCase				)





				def 					a__(		self      :			int				)->					Any:

										"""simple docstring"""




										UpperCAmelCase					    =     get_activation('''gelu'''				)
										UpperCAmelCase					    =     1
										UpperCAmelCase					    =     get_activation('''gelu'''				)
										self.assertEqual(acta.a				,   1				)
										with self.assertRaises(lowerCAmelCase				):
																UpperCAmelCase					    =     acta.a









'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase      :      List[Any]            =					{
    """configuration_x_clip""": [
        """XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """XCLIPConfig""",
        """XCLIPTextConfig""",
        """XCLIPVisionConfig""",
    ],
    """processing_x_clip""": ["""XCLIPProcessor"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase      :      List[str]            =					[
	    """XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """XCLIPModel""",
	    """XCLIPPreTrainedModel""",
	    """XCLIPTextModel""",
	    """XCLIPVisionModel""",
	]

if TYPE_CHECKING:
	from .configuration_x_clip import (
	    XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    XCLIPConfig,
	    XCLIPTextConfig,
	    XCLIPVisionConfig,
	)
	from .processing_x_clip import XCLIPProcessor

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_x_clip import (
		    XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
		    XCLIPModel,
		    XCLIPPreTrainedModel,
		    XCLIPTextModel,
		    XCLIPVisionModel,
		)

else:
	import sys

	_lowercase      :      List[Any]            =					_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





