






"""simple docstring"""







from hashlib import mda, shaaaa

UpperCamelCase_       :       Optional[Any]							   =		(shaaaa, mda)


class 			_lowercase		:

				def __init__(     self       :    int       ,    _lowercase       :    int = 8     ):


										'''simple docstring'''
										UpperCAmelCase__						=		0b0
										UpperCAmelCase__						=		size

				def        A (     self       :    str       ,    _lowercase       :    int     ):


										'''simple docstring'''
										UpperCAmelCase__						=		self.hash_(__SCREAMING_SNAKE_CASE     )
										self.bitarray |= h

				def        A (     self       :    int       ,    _lowercase       :    Tuple     ):


										'''simple docstring'''
										UpperCAmelCase__						=		self.hash_(__SCREAMING_SNAKE_CASE     )
										return (h & self.bitarray) == h

				def __contains__(     self       :    Optional[int]       ,    _lowercase       :    Dict     ):


										'''simple docstring'''
										return self.exists(__SCREAMING_SNAKE_CASE     )

				def        A (     self       :    Any       ,    _lowercase       :    str     ):


										'''simple docstring'''
										UpperCAmelCase__						=		bin(__SCREAMING_SNAKE_CASE     )[2:]
										return res.zfill(self.size     )

				@property
				def        A (     self       :    Any     ):


										'''simple docstring'''
										return self.format_bin(self.bitarray     )

				def        A (     self       :    Optional[int]       ,    _lowercase       :    Dict     ):


										'''simple docstring'''
										UpperCAmelCase__						=		0b0
										for func in HASH_FUNCTIONS:
																UpperCAmelCase__						=		(
																    int.from_bytes(func(value.encode()     ).digest()       ,    """little"""     ) % self.size
																)
																res |= 2**position
										return res

				def        A (     self       :    str       ,    _lowercase       :    int     ):


										'''simple docstring'''
										return self.format_bin(self.hash_(__SCREAMING_SNAKE_CASE     )     )

				@property
				def        A (     self       :    int     ):


										'''simple docstring'''
										UpperCAmelCase__						=		bin(self.bitarray     ).count("""1"""     )
										return (n_ones / self.size) ** len(__SCREAMING_SNAKE_CASE     )


"""simple docstring"""







import unittest

import numpy as np

from transformers import is_tf_available
from transformers.testing_utils import require_tf


if is_tf_available():
						import tensorflow as tf

						from transformers.activations_tf import get_tf_activation


@require_tf
class 			_lowercase		(   unittest.TestCase  ):

				def        A (     self       :    Any     ):


										'''simple docstring'''
										UpperCAmelCase__						=		tf.constant([-1_0_0, -1.0, -0.1, 0, 0.1, 1.0, 100.0]     )
										UpperCAmelCase__						=		get_tf_activation("""gelu"""     )
										UpperCAmelCase__						=		get_tf_activation("""gelu_10"""     )

										UpperCAmelCase__						=		gelu(_lowercase     )
										UpperCAmelCase__						=		geluaa(_lowercase     )

										UpperCAmelCase__						=		tf.where(y_gelu_aa < 10.0       ,    1.0       ,    0.0     )

										self.assertEqual(tf.math.reduce_max(_lowercase     ).numpy().item()       ,    10.0     )
										self.assertTrue(np.allclose(y_gelu * clipped_mask       ,    y_gelu_aa * clipped_mask     )     )

				def        A (     self       :    Optional[Any]     ):


										'''simple docstring'''
										get_tf_activation("""gelu"""     )
										get_tf_activation("""gelu_10"""     )
										get_tf_activation("""gelu_fast"""     )
										get_tf_activation("""gelu_new"""     )
										get_tf_activation("""glu"""     )
										get_tf_activation("""mish"""     )
										get_tf_activation("""quick_gelu"""     )
										get_tf_activation("""relu"""     )
										get_tf_activation("""sigmoid"""     )
										get_tf_activation("""silu"""     )
										get_tf_activation("""swish"""     )
										get_tf_activation("""tanh"""     )
										with self.assertRaises(_lowercase     ):
																get_tf_activation("""bogus"""     )
										with self.assertRaises(_lowercase     ):
																get_tf_activation(_lowercase     )

