



'''simple docstring'''





import math

import tensorflow as tf
from packaging import version




def 							lowerCamelCase	(					_snake_case	:    List[str]							):





    '''simple docstring'''


    lowercase__									=    tf.convert_to_tensor(__lowerCAmelCase							)
    lowercase__									=    0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0							)  ,x.dtype							)							))

    return x * cdf




def 							lowerCamelCase	(					_snake_case	:    str							):





    '''simple docstring'''


    lowercase__									=    tf.convert_to_tensor(__lowerCAmelCase							)
    lowercase__									=    tf.cast(math.pi  ,x.dtype							)
    lowercase__									=    tf.cast(0.044_715  ,x.dtype							)
    lowercase__									=    0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi							) * (x + coeff * tf.pow(__lowerCAmelCase  ,3							))							))

    return x * cdf




def 							lowerCamelCase	(					_snake_case	:    int							):





    '''simple docstring'''


    lowercase__									=    tf.convert_to_tensor(__lowerCAmelCase							)

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




def 							lowerCamelCase	(					_snake_case	:    Optional[int]							):





    '''simple docstring'''


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





    '''simple docstring'''


    lowercase__									=    tf.convert_to_tensor(__lowerCAmelCase							)
    lowercase__									=    tf.cast(1.702  ,x.dtype							)
    return x * tf.math.sigmoid(coeff * x							)




def 							lowerCamelCase	(					_snake_case	:    Dict							):





    '''simple docstring'''


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




def 							lowerCamelCase	(					_snake_case	:    List[Any]  ,_snake_case	:    Optional[Any]=-1							):





    '''simple docstring'''


    lowercase__									=    tf.split(__lowerCAmelCase  ,2  ,axis=__lowerCAmelCase							)
    return a * tf.math.sigmoid(__lowerCAmelCase							)


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




 def 							lowerCamelCase	(					_snake_case	:    Tuple							):





     '''simple docstring'''


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

 SCREAMING_SNAKE_CASE__          =  tf.keras.activations.gelu



 SCREAMING_SNAKE_CASE__          =  approximate_gelu_wrap
else:
 SCREAMING_SNAKE_CASE__          =  _gelu
 SCREAMING_SNAKE_CASE__          =  _gelu_new


SCREAMING_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 							lowerCamelCase	(					_snake_case	:    str							):





    '''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()							)}'''							)












UpperCamelCase    							=      8.3_144_598


def 				__lowerCamelCase     (							__lowerCAmelCase							:					float					,							__lowerCAmelCase							:					float							)     ->  float:
   if temperature < 0:
      raise Exception("""Temperature cannot be less than 0 K"""							)
   if molar_mass <= 0:
      raise Exception("""Molar mass cannot be less than or equal to 0 kg/mol"""							)
   else:
      return (3 * UNIVERSAL_GAS_CONSTANT * temperature / molar_mass) ** 0.5


if __name__ == "__main__":
       import doctest

       # run doctest
       doctest.testmod()

       # example
       UpperCamelCase    							=      300
       UpperCamelCase    							=      28
       UpperCamelCase    							=      rms_speed_of_molecule(temperature, molar_mass)
       print(F"""Vrms of Nitrogen gas at 300 K is {vrms} m/s""")



