





"""simple docstring"""



import math

import tensorflow as tf
from packaging import version







def 		__lowercase					(       snake_case_  :  Any						)       ->Union[str, Any]:



    '''simple docstring'''







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

    return x * cdf







def 		__lowercase					(       snake_case_  :  Dict						)       ->str:



    '''simple docstring'''







    __A   :						List[str]									=					tf.convert_to_tensor(lowerCAmelCase_						)
    __A   :						Optional[int]									=					tf.cast(math.pi    ,x.dtype						)
    __A   :						Dict									=					tf.cast(0.044_715    ,x.dtype						)
    __A   :						Any									=					0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi						) * (x + coeff * tf.pow(lowerCAmelCase_    ,3						))						))

    return x * cdf







def 		__lowercase					(       snake_case_  :  Optional[Any]						)       ->Union[str, Any]:



    '''simple docstring'''







    __A   :						Optional[Any]									=					tf.convert_to_tensor(lowerCAmelCase_						)

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







def 		__lowercase					(       snake_case_  :  Union[str, Any]						)       ->List[str]:



    '''simple docstring'''







    __A   :						Union[str, Any]									=					tf.convert_to_tensor(lowerCAmelCase_						)
    __A   :						Union[str, Any]									=					tf.cast(0.044_715    ,x.dtype						)
    __A   :						Dict									=					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 		__lowercase					(       snake_case_  :  Optional[int]						)       ->Optional[int]:



    '''simple docstring'''







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







def 		__lowercase					(       snake_case_  :  Dict						)       ->Dict:



    '''simple docstring'''







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







def 		__lowercase					(       snake_case_  :  Optional[int]    ,snake_case_  :  List[str]=-1						)       ->List[Any]:



    '''simple docstring'''







    __A   :						List[str]									=					tf.split(lowerCAmelCase_    ,2    ,axis=lowerCAmelCase_						)
    return a * tf.math.sigmoid(lowerCAmelCase_						)


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







       def 		__lowercase					(       snake_case_  :  Any						)       ->Union[str, Any]:



           '''simple docstring'''







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

       a_			=      tf.keras.activations.gelu




       a_			=      approximate_gelu_wrap
else:
       a_			=      _gelu
       a_			=      _gelu_new


a_			=      {
    """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 		__lowercase					(       snake_case_  :  Dict						)       ->Optional[int]:



    '''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 typing import TYPE_CHECKING

from ....utils import _LazyModule


a_			=      {"""tokenization_tapex""": ["""TapexTokenizer"""]}


if TYPE_CHECKING:
       from .tokenization_tapex import TapexTokenizer


else:
       import sys

       a_			=      _LazyModule(__name__, globals()["""__file__"""], _import_structure)




