





'''simple docstring'''




import math

import tensorflow as tf
from packaging import version






def 	_lowerCAmelCase      (  __snake_case  :			List[Any]      )					->					Tuple:
     __A						:			str								=	tf.convert_to_tensor(__snake_case      )
     __A						:			Optional[int]								=	0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0      )			,							x.dtype      )      ))

     return x * cdf






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

     return x * cdf






def 	_lowerCAmelCase      (  __snake_case  :			List[str]      )					->					Dict:
     __A						:			Dict								=	tf.convert_to_tensor(__snake_case      )

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






def 	_lowerCAmelCase      (  __snake_case  :			Optional[Any]      )					->					Optional[Any]:
     __A						:			int								=	tf.convert_to_tensor(__snake_case      )
     __A						:			Any								=	tf.cast(0.044_715			,							x.dtype      )
     __A						:			str								=	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  :			Optional[int]      )					->					str:
     __A						:			Tuple								=	tf.convert_to_tensor(__snake_case      )
     __A						:			str								=	tf.cast(1.702			,							x.dtype      )
     return x * tf.math.sigmoid(coeff * x      )






def 	_lowerCAmelCase      (  __snake_case  :			Optional[int]      )					->					Any:
     return tf.clip_by_value(_gelu(__snake_case      )			,							-10			,							10      )






def 	_lowerCAmelCase      (  __snake_case  :			int			,							__snake_case  :			str=-1      )					->					Union[str, Any]:
     __A			,__A						:			str								=	tf.split(__snake_case			,							2			,							axis=__snake_case      )
     return a * tf.math.sigmoid(__snake_case      )


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






  def 	_lowerCAmelCase      (  __snake_case  :			Union[str, Any]      )					->					Optional[int]:
       return tf.keras.activations.gelu(__snake_case			,							approximate=__snake_case      )

  lowercase__   :				Optional[int]      =   tf.keras.activations.gelu







  lowercase__   :				int      =   approximate_gelu_wrap
else:
  lowercase__   :				Any      =   _gelu
  lowercase__   :				Any      =   _gelu_new


lowercase__   :				Optional[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 	_lowerCAmelCase      (  __snake_case  :			Union[str, Any]      )					->					str:
     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 math






def 	_lowerCAmelCase      (  __snake_case  :			int      )					->					bool:

     if 1 < number < 4:
          # 2 and 3 are primes
          return True
     elif number < 2 or number % 2 == 0 or number % 3 == 0:
          # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
          return False

     # All primes number are in format of 6k +/- 1
     for i in range(5			,							int(math.sqrt(__snake_case      ) + 1      )			,							6      ):
          if number % i == 0 or number % (i + 2) == 0:
               return False
     return True






def 	_lowerCAmelCase      (  __snake_case  :			float = 0.1      )					->					int:
     __A						:			Dict								=	3
     __A						:			int								=	3

     while primes / (2 * j - 1) >= ratio:
          for i in range(j * j + j + 1			,							(j + 2) * (j + 2)			,							j + 1      ):
               primes += is_prime(__snake_case      )
          j += 2
     return j


if __name__ == "__main__":
  import doctest

  doctest.testmod()