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






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     str													=       torch.tensor([-1_00, -1, -0.1, 0, 0.1, 1.0, 1_00]		)
											lowercase_	:     Union[str, Any]													=       get_activation('''gelu'''		)
											self.assertTrue(torch.allclose(gelu_python(__SCREAMING_SNAKE_CASE		)				,							torch_builtin(__SCREAMING_SNAKE_CASE		)		)		)
											self.assertFalse(torch.allclose(gelu_python(__SCREAMING_SNAKE_CASE		)				,							gelu_new(__SCREAMING_SNAKE_CASE		)		)		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     Optional[Any]													=       torch.tensor([-1_00, -1, -0.1, 0, 0.1, 1.0, 1_00]		)
											lowercase_	:     Tuple													=       get_activation('''gelu'''		)
											lowercase_	:     Any													=       get_activation('''gelu_10'''		)

											lowercase_	:     List[str]													=       torch_builtin(__SCREAMING_SNAKE_CASE		)
											lowercase_	:     Union[str, Any]													=       geluaa(__SCREAMING_SNAKE_CASE		)

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

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






					def 	_snake_case    (   self		):


											"""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(__SCREAMING_SNAKE_CASE		):
																	get_activation('''bogus'''		)
											with self.assertRaises(__SCREAMING_SNAKE_CASE		):
																	get_activation(__SCREAMING_SNAKE_CASE		)






					def 	_snake_case    (   self		):


											"""simple docstring"""





											lowercase_	:     int													=       get_activation('''gelu'''		)
											lowercase_	:     Any													=       1
											lowercase_	:     str													=       get_activation('''gelu'''		)
											self.assertEqual(acta.a				,							1		)
											with self.assertRaises(__SCREAMING_SNAKE_CASE		):
																	lowercase_	:     Dict													=       acta.a





'''simple docstring'''







_lowercase :  int    							=       [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)]
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int							):



						"""simple docstring"""





						lowercase_	:     Optional[int]													=       0
						while number:
												# Increased Speed Slightly by checking every 5 digits together.
												sum_of_digits_squared += DIGITS_SQUARED[number % 100000]
												number //= 100000

						return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
_lowercase :  list[bool | None]    							=       [None] * 1_0_0_0_0_0_0_0
_lowercase :  List[str]    							=       True
_lowercase :  Optional[int]    							=       False
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int							):



						"""simple docstring"""





						if CHAINS[number - 1] is not None:
												return CHAINS[number - 1]  # type: ignore

						lowercase_	:     Tuple													=       chain(next_number(__SCREAMING_SNAKE_CASE							)							)
						lowercase_	:     Union[str, Any]													=       number_chain

						while number < 10000000:
												lowercase_	:     int													=       number_chain
												number *= 10

						return number_chain
def 					snake_case_		(				__SCREAMING_SNAKE_CASE					: int = 10000000							):



						"""simple docstring"""





						for i in range(1      ,      __SCREAMING_SNAKE_CASE							):
												if CHAINS[i] is None:
																		chain(i + 1							)

						return CHAINS[:number].count(__SCREAMING_SNAKE_CASE							)


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							print(f"""{solution() = }""")



