



'''simple docstring'''


import math

import tensorflow as tf
from packaging import version







def 				__lowerCamelCase				(   A__    )       ->	Optional[int]:






   """simple docstring"""
   UpperCamelCase					=  tf.convert_to_tensor(A__    )
   UpperCamelCase					=  0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0    )    ,						x.dtype    )    ))

   return x * cdf







def 				__lowerCamelCase				(   A__    )       ->	Any:






   """simple docstring"""
   UpperCamelCase					=  tf.convert_to_tensor(A__    )
   UpperCamelCase					=  tf.cast(math.pi    ,						x.dtype    )
   UpperCamelCase					=  tf.cast(0.044_715    ,						x.dtype    )
   UpperCamelCase					=  0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi    ) * (x + coeff * tf.pow(A__    ,						3    ))    ))

   return x * cdf







def 				__lowerCamelCase				(   A__    )       ->	str:






   """simple docstring"""
   UpperCamelCase					=  tf.convert_to_tensor(A__    )

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







def 				__lowerCamelCase				(   A__    )       ->	List[str]:






   """simple docstring"""
   UpperCamelCase					=  tf.convert_to_tensor(A__    )
   UpperCamelCase					=  tf.cast(0.044_715    ,						x.dtype    )
   UpperCamelCase					=  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				(   A__    )       ->	List[str]:






   """simple docstring"""
   UpperCamelCase					=  tf.convert_to_tensor(A__    )
   UpperCamelCase					=  tf.cast(1.702    ,						x.dtype    )
   return x * tf.math.sigmoid(coeff * x    )







def 				__lowerCamelCase				(   A__    )       ->	Optional[int]:






   """simple docstring"""
   return tf.clip_by_value(_gelu(A__    )    ,						-10    ,						10    )







def 				__lowerCamelCase				(   A__    ,						A__=-1    )       ->	Optional[Any]:






   """simple docstring"""
   UpperCamelCase				,      UpperCamelCase					=  tf.split(A__    ,						2    ,						axis=A__    )
   return a * tf.math.sigmoid(A__    )


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







   def 				__lowerCamelCase				(   A__    )       ->	str:






      """simple docstring"""
      return tf.keras.activations.gelu(A__    ,						approximate=A__    )

   _lowerCamelCase	:       Union[str, Any]      	=	tf.keras.activations.gelu
   _lowerCamelCase	:       Dict      	=	approximate_gelu_wrap
else:
   _lowerCamelCase	:       Tuple      	=	_gelu
   _lowerCamelCase	:       Optional[Any]      	=	_gelu_new


_lowerCamelCase	:       str      	=	{
    "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				(   A__    )       ->	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'''


import math

class  SCREAMING_SNAKE_CASE :






    """simple docstring"""





    def __init__(  self      :					Union[str, Any]  ,						UpperCamelCase__      :					Optional[Any]=0 ):  # a graph with Node 0,1,...,N-1


       """simple docstring"""







       UpperCamelCase					=  n
       UpperCamelCase					=  [
           [math.inf for j in range(0  ,						UpperCamelCase__ )] for i in range(0  ,						UpperCamelCase__ )
       ]  # adjacency matrix for weight
       UpperCamelCase					=  [
           [math.inf for j in range(0  ,						UpperCamelCase__ )] for i in range(0  ,						UpperCamelCase__ )
       ]  # dp[i][j] stores minimum distance from i to j






    def  A       (  self      :					Optional[Any]  ,						UpperCamelCase__      :					Union[str, Any]  ,						UpperCamelCase__      :					Union[str, Any]  ,						UpperCamelCase__      :					Tuple ):


       """simple docstring"""







       UpperCamelCase					=  w






    def  A       (  self      :					str ):


       """simple docstring"""







       for k in range(0  ,						self.n ):
          for i in range(0  ,						self.n ):
             for j in range(0  ,						self.n ):
                UpperCamelCase					=  min(self.dp[i][j]  ,						self.dp[i][k] + self.dp[k][j] )






    def  A       (  self      :					Optional[Any]  ,						UpperCamelCase__      :					str  ,						UpperCamelCase__      :					List[Any] ):


       """simple docstring"""







       return self.dp[u][v]


if __name__ == "__main__":
   _lowerCamelCase	:       List[str]      	=	Graph(5)
   graph.add_edge(0, 2, 9)
   graph.add_edge(0, 4, 10)
   graph.add_edge(1, 3, 5)
   graph.add_edge(2, 3, 7)
   graph.add_edge(3, 0, 10)
   graph.add_edge(3, 1, 2)
   graph.add_edge(3, 2, 1)
   graph.add_edge(3, 4, 6)
   graph.add_edge(4, 1, 3)
   graph.add_edge(4, 2, 4)
   graph.add_edge(4, 3, 9)
   graph.floyd_warshall()
   graph.show_min(1, 4)
   graph.show_min(0, 3)

