





'''simple docstring'''






import math

import tensorflow as tf
from packaging import version
def    UpperCamelCase__      (		lowerCAmelCase  ):





      """simple docstring"""


      _lowerCAmelCase							     =							tf.convert_to_tensor(lowerCAmelCase  )
      _lowerCAmelCase							     =							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							     =							tf.convert_to_tensor(lowerCAmelCase  )
      _lowerCAmelCase							     =							tf.cast(math.pi							,	x.dtype  )
      _lowerCAmelCase							     =							tf.cast(0.044_715							,	x.dtype  )
      _lowerCAmelCase							     =							0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi  ) * (x + coeff * tf.pow(lowerCAmelCase							,	3  ))  ))

      return x * cdf
def    UpperCamelCase__      (		lowerCAmelCase  ):





      """simple docstring"""


      _lowerCAmelCase							     =							tf.convert_to_tensor(lowerCAmelCase  )

      return x * tf.tanh(tf.math.softplus(lowerCAmelCase  )  )
def    UpperCamelCase__      (		lowerCAmelCase  ):





      """simple docstring"""


      _lowerCAmelCase							     =							tf.convert_to_tensor(lowerCAmelCase  )
      _lowerCAmelCase							     =							tf.cast(0.044_715							,	x.dtype  )
      _lowerCAmelCase							     =							tf.cast(0.7_978_845_608							,	x.dtype  )

      return 0.5 * x * (1.0 + tf.tanh(x * coeffa * (1.0 + coeffa * x * x)  ))
def    UpperCamelCase__      (		lowerCAmelCase  ):





      """simple docstring"""


      _lowerCAmelCase							     =							tf.convert_to_tensor(lowerCAmelCase  )
      _lowerCAmelCase							     =							tf.cast(1.702							,	x.dtype  )
      return x * tf.math.sigmoid(coeff * x  )
def    UpperCamelCase__      (		lowerCAmelCase  ):





      """simple docstring"""


      return tf.clip_by_value(_gelu(lowerCAmelCase  )							,	-10							,	10  )
def    UpperCamelCase__      (		lowerCAmelCase							,	lowerCAmelCase=-1  ):





      """simple docstring"""


      _lowerCAmelCase     ,							_lowerCAmelCase							     =							tf.split(lowerCAmelCase							,	2							,	axis=lowerCAmelCase  )
      return a * tf.math.sigmoid(lowerCAmelCase  )


if version.parse(tf.version.VERSION) >= version.parse('''2.4'''):
      def    UpperCamelCase__      (		lowerCAmelCase  ):





            """simple docstring"""


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

      A__				:   Optional[Any]      =tf.keras.activations.gelu





      A__				:   Optional[int]      =approximate_gelu_wrap
else:
      A__				:   Union[str, Any]      =_gelu
      A__				:   Any      =_gelu_new


A__				:   Dict      ={
    '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()  )}"  )












import numpy as np




def 			__magic_name__				( A		:					np.array   ):






			'''simple docstring'''







			return 1 / (1 + np.exp(-vector   ))




def 			__magic_name__				( A		:					np.array   ):






			'''simple docstring'''







			return vector * sigmoid(1.7_02 * vector   )


if __name__ == "__main__":
		import doctest

		doctest.testmod()






