

"""simple docstring"""
import math

import tensorflow as tf
from packaging import version




def 					a__						(						lowerCAmelCase    )	-> List[Any]:
      UpperCAmelCase__			:							str							=    tf.convert_to_tensor(lowerCAmelCase    )
      UpperCAmelCase__			:							int							=    0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0    )			,	x.dtype    )    ))

      return x * cdf




def 					a__						(						lowerCAmelCase    )	-> Optional[Any]:
      UpperCAmelCase__			:							Dict							=    tf.convert_to_tensor(lowerCAmelCase    )
      UpperCAmelCase__			:							Optional[Any]							=    tf.cast(math.pi			,	x.dtype    )
      UpperCAmelCase__			:							Union[str, Any]							=    tf.cast(0.04_4715			,	x.dtype    )
      UpperCAmelCase__			:							Any							=    0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi    ) * (x + coeff * tf.pow(lowerCAmelCase			,	3    ))    ))

      return x * cdf




def 					a__						(						lowerCAmelCase    )	-> Tuple:
      UpperCAmelCase__			:							List[str]							=    tf.convert_to_tensor(lowerCAmelCase    )

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




def 					a__						(						lowerCAmelCase    )	-> List[str]:
      UpperCAmelCase__			:							Dict							=    tf.convert_to_tensor(lowerCAmelCase    )
      UpperCAmelCase__			:							Dict							=    tf.cast(0.04_4715			,	x.dtype    )
      UpperCAmelCase__			:							Optional[int]							=    tf.cast(0.79_7884_5608			,	x.dtype    )

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




def 					a__						(						lowerCAmelCase    )	-> List[str]:
      UpperCAmelCase__			:							str							=    tf.convert_to_tensor(lowerCAmelCase    )
      UpperCAmelCase__			:							Any							=    tf.cast(1.702			,	x.dtype    )
      return x * tf.math.sigmoid(coeff * x    )




def 					a__						(						lowerCAmelCase    )	-> Optional[Any]:
      return tf.clip_by_value(_gelu(lowerCAmelCase    )			,	-10			,	10    )




def 					a__						(						lowerCAmelCase			,	lowerCAmelCase=-1    )	-> List[str]:
      UpperCAmelCase__					,		UpperCAmelCase__			:							Dict							=    tf.split(lowerCAmelCase			,	2			,	axis=lowerCAmelCase    )
      return a * tf.math.sigmoid(lowerCAmelCase    )


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




    def 					a__						(						lowerCAmelCase    )	-> int:
          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 					a__						(						lowerCAmelCase    )	-> int:
      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"""



def 	_lowerCamelCase(	a   ,    a				):
       __a       =    0
       __a       =    len(a				) - 1

       while left <= right:
              # avoid divided by 0 during interpolation
              if sorted_collection[left] == sorted_collection[right]:
                     if sorted_collection[left] == item:
                            return left
                     else:
                            return None

              __a       =    left + ((item - sorted_collection[left]) * (right - left)) // (
                  sorted_collection[right] - sorted_collection[left]
              )

              # out of range check
              if point < 0 or point >= len(a				):
                     return None

              __a       =    sorted_collection[point]
              if current_item == item:
                     return point
              else:
                     if point < left:
                            __a       =    left
                            __a       =    point
                     elif point > right:
                            __a       =    right
                            __a       =    point
                     else:
                            if item < current_item:
                                   __a       =    point - 1
                            else:
                                   __a       =    point + 1
       return None



def 	_lowerCamelCase(	a   ,    a   ,    a   ,    a				):

       # avoid divided by 0 during interpolation
       if sorted_collection[left] == sorted_collection[right]:
              if sorted_collection[left] == item:
                     return left
              else:
                     return None

       __a       =    left + ((item - sorted_collection[left]) * (right - left)) // (
           sorted_collection[right] - sorted_collection[left]
       )

       # out of range check
       if point < 0 or point >= len(a				):
              return None

       if sorted_collection[point] == item:
              return point
       elif point < left:
              return interpolation_search_by_recursion(a   ,    a   ,    a   ,    a				)
       elif point > right:
              return interpolation_search_by_recursion(a   ,    a   ,    a   ,    a				)
       else:
              if sorted_collection[point] > item:
                     return interpolation_search_by_recursion(
                         a   ,    a   ,    a   ,    point - 1				)
              else:
                     return interpolation_search_by_recursion(
                         a   ,    a   ,    point + 1   ,    a				)



def 	_lowerCamelCase(	a				):
       if collection != sorted(a				):
              raise ValueError("Collection must be ascending sorted"				)
       return True


if __name__ == "__main__":
   import sys
   SCREAMING_SNAKE_CASE__:List[str]									=			0
   if debug == 1:
      SCREAMING_SNAKE_CASE__:Tuple									=			[10, 30, 40, 45, 50, 66, 77, 93]
      try:
         __assert_sorted(collection)
      except ValueError:
         sys.exit("""Sequence must be ascending sorted to apply interpolation search""")
      SCREAMING_SNAKE_CASE__:int									=			67

   SCREAMING_SNAKE_CASE__:List[str]									=			interpolation_search(collection, target)
   if result is not None:
      print(F'''{target} found at positions: {result}''')
   else:
      print("""Not found""")
