
"""simple docstring"""





import math

import tensorflow as tf
from packaging import version
def 							A_     (__a				):

					'''simple docstring'''





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

					return x * cdf
def 							A_     (__a				):

					'''simple docstring'''





					A_				 =						tf.convert_to_tensor(__a				)
					A_				 =						tf.cast(math.pi				,   x.dtype				)
					A_				 =						tf.cast(0.044715				,   x.dtype				)
					A_				 =						0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi				) * (x + coeff * tf.pow(__a				,   3				))				))

					return x * cdf
def 							A_     (__a				):

					'''simple docstring'''





					A_				 =						tf.convert_to_tensor(__a				)

					return x * tf.tanh(tf.math.softplus(__a				)				)
def 							A_     (__a				):

					'''simple docstring'''





					A_				 =						tf.convert_to_tensor(__a				)
					A_				 =						tf.cast(0.044715				,   x.dtype				)
					A_				 =						tf.cast(0.7978845608				,   x.dtype				)

					return 0.5 * x * (1.0 + tf.tanh(x * coeffa * (1.0 + coeffa * x * x)				))
def 							A_     (__a				):

					'''simple docstring'''





					A_				 =						tf.convert_to_tensor(__a				)
					A_				 =						tf.cast(1.702				,   x.dtype				)
					return x * tf.math.sigmoid(coeff * x				)
def 							A_     (__a				):

					'''simple docstring'''





					return tf.clip_by_value(_gelu(__a				)				,   -10				,   10				)
def 							A_     (__a				,   __a=-1				):

					'''simple docstring'''





					A_ ,    A_				 =						tf.split(__a				,   2				,   axis=__a				)
					return a * tf.math.sigmoid(__a				)


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

							'''simple docstring'''





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

		UpperCamelCase_					:						str				= tf.keras.activations.gelu




		UpperCamelCase_					:						List[Any]				= approximate_gelu_wrap
else:
		UpperCamelCase_					:						Any				= _gelu
		UpperCamelCase_					:						List[str]				= _gelu_new


UpperCamelCase_					:						Tuple				= {
    '''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_     (__a				):

					'''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 math import atan, cos, radians, sin, tan

from .haversine_distance import haversine_distance

UpperCamelCase_					:						Tuple				= 637_8137.0
UpperCamelCase_					:						List[str]				= 635_6752.31_4245
UpperCamelCase_					:						Dict				= 637_8137
def 							A_     (__a				,   __a				,   __a				,   __a				):

					'''simple docstring'''





					A_				 =						(AXIS_A - AXIS_B) / AXIS_A
					# Parametric latitudes
					# https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
					A_				 =						atan((1 - flattening) * tan(radians(__a				)				)				)
					A_				 =						atan((1 - flattening) * tan(radians(__a				)				)				)

					# Compute central angle between two points
					# using haversine theta. sigma =  haversine_distance / equatorial radius
					A_				 =						haversine_distance(__a				,   __a				,   __a				,   __a				) / EQUATORIAL_RADIUS

					# Intermediate P and Q values
					A_				 =						(b_lata + b_lata) / 2
					A_				 =						(b_lata - b_lata) / 2

					# Intermediate X value
					# X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
					A_				 =						(sin(__a				) ** 2) * (cos(__a				) ** 2)
					A_				 =						cos(sigma / 2				) ** 2
					A_				 =						(sigma - sin(__a				)) * (x_numerator / x_demonimator)

					# Intermediate Y value
					# Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
					A_				 =						(cos(__a				) ** 2) * (sin(__a				) ** 2)
					A_				 =						sin(sigma / 2				) ** 2
					A_				 =						(sigma + sin(__a				)) * (y_numerator / y_denominator)

					return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
		import doctest

		doctest.testmod()




