



"""simple docstring"""

import math

import tensorflow as tf
from packaging import version







def 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	Any      ):



					"""simple docstring"""





					snake_case_       :		str			       =       tf.convert_to_tensor(__UpperCAmelCase      )
					snake_case_       :		int			       =       0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0      )					,     x.dtype      )      ))

					return x * cdf







def 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	Optional[int]      ):



					"""simple docstring"""





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

					return x * cdf







def 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	Tuple      ):



					"""simple docstring"""





					snake_case_       :		Optional[int]			       =       tf.convert_to_tensor(__UpperCAmelCase      )

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







def 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	Optional[Any]      ):



					"""simple docstring"""





					snake_case_       :		List[str]			       =       tf.convert_to_tensor(__UpperCAmelCase      )
					snake_case_       :		Dict			       =       tf.cast(0.04_4715					,     x.dtype      )
					snake_case_       :		List[str]			       =       tf.cast(0.79_7884_5608					,     x.dtype      )

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







def 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	int      ):



					"""simple docstring"""





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







def 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	Optional[int]      ):



					"""simple docstring"""





					return tf.clip_by_value(_gelu(__UpperCAmelCase      )					,     -1_0					,     1_0      )







def 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	Any					,     SCREAMING_SNAKE_CASE__			:	Optional[int]=-1      ):



					"""simple docstring"""





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


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







			def 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	List[Any]      ):



								"""simple docstring"""





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

			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 				SCREAMING_SNAKE_CASE__   (		SCREAMING_SNAKE_CASE__			:	Optional[Any]      ):



					"""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'''

import os


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_doctest_list.py
a							   =				'.'


if __name__ == "__main__":
	a							   =				os.path.join(REPO_PATH, 'utils/documentation_tests.txt')
	a							   =				[]
	a							   =				[]
	with open(doctest_file_path) as fp:
		for line in fp:
			a							   =				line.strip()
			a							   =				os.path.join(REPO_PATH, line)
			if not (os.path.isfile(path) or os.path.isdir(path)):
				non_existent_paths.append(line)
			all_paths.append(path)
	if len(non_existent_paths) > 0:
		a							   =				'\n'.join(non_existent_paths)
		raise ValueError(F"""`utils/documentation_tests.txt` contains non-existent paths:\n{non_existent_paths}""")
	if all_paths != sorted(all_paths):
		raise ValueError('Files in `utils/documentation_tests.txt` are not in alphabetical order.')




