





'''simple docstring'''

import math

import tensorflow as tf
from packaging import version




def    _a    (							lowerCAmelCase_	):





      """simple docstring"""



      _snake_case		:	int					     =     tf.convert_to_tensor(lowerCAmelCase_	)
      _snake_case		:	List[str]					     =     0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0	)			,      x.dtype	)	))

      return x * cdf




def    _a    (							lowerCAmelCase_	):





      """simple docstring"""



      _snake_case		:	Tuple					     =     tf.convert_to_tensor(lowerCAmelCase_	)
      _snake_case		:	str					     =     tf.cast(math.pi			,      x.dtype	)
      _snake_case		:	Dict					     =     tf.cast(0.044_715			,      x.dtype	)
      _snake_case		:	int					     =     0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi	) * (x + coeff * tf.pow(lowerCAmelCase_			,      3	))	))

      return x * cdf




def    _a    (							lowerCAmelCase_	):





      """simple docstring"""



      _snake_case		:	int					     =     tf.convert_to_tensor(lowerCAmelCase_	)

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




def    _a    (							lowerCAmelCase_	):





      """simple docstring"""



      _snake_case		:	Any					     =     tf.convert_to_tensor(lowerCAmelCase_	)
      _snake_case		:	List[str]					     =     tf.cast(0.044_715			,      x.dtype	)
      _snake_case		:	Any					     =     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    _a    (							lowerCAmelCase_	):





      """simple docstring"""



      _snake_case		:	Tuple					     =     tf.convert_to_tensor(lowerCAmelCase_	)
      _snake_case		:	Tuple					     =     tf.cast(1.702			,      x.dtype	)
      return x * tf.math.sigmoid(coeff * x	)




def    _a    (							lowerCAmelCase_	):





      """simple docstring"""



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




def    _a    (							lowerCAmelCase_			,      lowerCAmelCase_=-1	):





      """simple docstring"""



      _snake_case     ,							_snake_case		:	Tuple					     =     tf.split(lowerCAmelCase_			,      2			,      axis=lowerCAmelCase_	)
      return a * tf.math.sigmoid(lowerCAmelCase_	)


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




   def    _a    (							lowerCAmelCase_	):





         """simple docstring"""



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

   UpperCAmelCase					:		int		=							tf.keras.activations.gelu
   UpperCAmelCase					:		Any		=							approximate_gelu_wrap
else:
   UpperCAmelCase					:		List[Any]		=							_gelu
   UpperCAmelCase					:		Any		=							_gelu_new


UpperCAmelCase					:		int		=							{
    '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    _a    (							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'''

from __future__ import annotations




def    _a    (							lowerCAmelCase_			,      lowerCAmelCase_ = None			,      lowerCAmelCase_ = None	):





      """simple docstring"""



      if start is None:
            _snake_case		:	Optional[Any]					     =     0

      if end is None:
            _snake_case		:	Any					     =     len(lowerCAmelCase_	) - 1

      if start >= end:
            return

      _snake_case		:	Optional[Any]					     =     (start + end) // 2

      slowsort(lowerCAmelCase_			,      lowerCAmelCase_			,      lowerCAmelCase_	)
      slowsort(lowerCAmelCase_			,      mid + 1			,      lowerCAmelCase_	)

      if sequence[end] < sequence[mid]:
            _snake_case     ,							_snake_case		:	int					     =     sequence[mid], sequence[end]

      slowsort(lowerCAmelCase_			,      lowerCAmelCase_			,      end - 1	)


if __name__ == "__main__":
   from doctest import testmod

   testmod()


