import math

import tensorflow as tf
from packaging import version






def        UpperCamelCase_							(			lowerCAmelCase__  ):



					"""simple docstring"""

					_lowerCAmelCase			:		Dict          = tf.convert_to_tensor(__UpperCAmelCase  )
					_lowerCAmelCase			:		Tuple          = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0  )						,	x.dtype  )  ))

					return x * cdf






def        UpperCamelCase_							(			lowerCAmelCase__  ):



					"""simple docstring"""

					_lowerCAmelCase			:		Any          = tf.convert_to_tensor(__UpperCAmelCase  )
					_lowerCAmelCase			:		Optional[Any]          = tf.cast(math.pi						,	x.dtype  )
					_lowerCAmelCase			:		List[str]          = tf.cast(0.04_4715						,	x.dtype  )
					_lowerCAmelCase			:		List[Any]          = 0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi  ) * (x + coeff * tf.pow(__UpperCAmelCase						,	3  ))  ))

					return x * cdf






def        UpperCamelCase_							(			lowerCAmelCase__  ):



					"""simple docstring"""

					_lowerCAmelCase			:		List[str]          = tf.convert_to_tensor(__UpperCAmelCase  )

					return x * tf.tanh(tf.math.softplus(__UpperCAmelCase  )  )






def        UpperCamelCase_							(			lowerCAmelCase__  ):



					"""simple docstring"""

					_lowerCAmelCase			:		Optional[Any]          = tf.convert_to_tensor(__UpperCAmelCase  )
					_lowerCAmelCase			:		Tuple          = tf.cast(0.04_4715						,	x.dtype  )
					_lowerCAmelCase			:		Any          = tf.cast(0.79_7884_5608						,	x.dtype  )

					return 0.5 * x * (1.0 + tf.tanh(x * coeffa * (1.0 + coeffa * x * x)  ))






def        UpperCamelCase_							(			lowerCAmelCase__  ):



					"""simple docstring"""

					_lowerCAmelCase			:		int          = tf.convert_to_tensor(__UpperCAmelCase  )
					_lowerCAmelCase			:		Union[str, Any]          = tf.cast(1.702						,	x.dtype  )
					return x * tf.math.sigmoid(coeff * x  )






def        UpperCamelCase_							(			lowerCAmelCase__  ):



					"""simple docstring"""

					return tf.clip_by_value(_gelu(__UpperCAmelCase  )						,	-10						,	10  )






def        UpperCamelCase_							(			lowerCAmelCase__						,	lowerCAmelCase__=-1  ):



					"""simple docstring"""

					_lowerCAmelCase      ,	_lowerCAmelCase			:		int          = tf.split(__UpperCAmelCase						,	2						,	axis=__UpperCAmelCase  )
					return a * tf.math.sigmoid(__UpperCAmelCase  )


if version.parse(tf.version.VERSION) >= version.parse("2.4"):






						def        UpperCamelCase_							(			lowerCAmelCase__  ):



											"""simple docstring"""

											return tf.keras.activations.gelu(__UpperCAmelCase						,	approximate=__UpperCAmelCase  )

						snake_case      =    tf.keras.activations.gelu

						snake_case      =    approximate_gelu_wrap
else:
						snake_case      =    _gelu
						snake_case      =    _gelu_new


snake_case      =    {
    'gelu': gelu,
    'gelu_10': gelu_aa,
    'gelu_fast': gelu_fast,
    'gelu_new': gelu_new,
    'glu': glu,
    'mish': mish,
    'quick_gelu': quick_gelu,
    'relu': tf.keras.activations.relu,
    'sigmoid': tf.keras.activations.sigmoid,
    'silu': tf.keras.activations.swish,
    'swish': tf.keras.activations.swish,
    'tanh': tf.keras.activations.tanh,
}






def        UpperCamelCase_							(			lowerCAmelCase__  ):



					"""simple docstring"""

					if activation_string in ACTaFN:
										return ACTaFN[activation_string]
					else:
										raise KeyError(f"""function {activation_string} not found in ACT2FN mapping {list(ACTaFN.keys()  )}"""  )












'''simple docstring'''

def 						__magic_name__       (      __UpperCAmelCase, __UpperCAmelCase      )						->   int:

					'''simple docstring'''

					return int((input_a, input_a).count(0      ) == 0      )


def 						__magic_name__       (      )						->   None:

					'''simple docstring'''

					assert and_gate(0, 0      ) == 0
					assert and_gate(0, 1      ) == 0
					assert and_gate(1, 0      ) == 0
					assert and_gate(1, 1      ) == 1


if __name__ == "__main__":
							test_and_gate()
							print(and_gate(1, 0))
							print(and_gate(0, 0))
							print(and_gate(0, 1))
							print(and_gate(1, 1))

