


import numpy as np

_snake_case	:						str         =							[
    ["a", "b", "c", "d", "e"],
    ["f", "g", "h", "i", "k"],
    ["l", "m", "n", "o", "p"],
    ["q", "r", "s", "t", "u"],
    ["v", "w", "x", "y", "z"],
]

class 							a						:




							"""simple docstring"""


							def __init__(				self			:    Optional[int]							)      ->       None:
														__snake_case						:     Optional[int]									=  np.array(lowerCamelCase							)

							def        __snake_case   (				self			:    Union[str, Any]       ,      lowerCamelCase			:    str							)      ->       np.ndarray:
														__snake_case					,     __snake_case						:     Optional[int]									=  np.where(letter == self.SQUARE							)
														__snake_case						:     Union[str, Any]									=  np.concatenate([indexa + 1, indexa + 1]							)
														return indexes

							def        __snake_case   (				self			:    Union[str, Any]       ,      lowerCamelCase			:    int       ,      lowerCamelCase			:    int							)      ->       str:
														__snake_case						:     Optional[int]									=  self.SQUARE[indexa - 1, indexa - 1]
														return letter

							def        __snake_case   (				self			:    Union[str, Any]       ,      lowerCamelCase			:    str							)      ->       str:
														__snake_case						:     Dict									=  message.lower()
														__snake_case						:     List[Any]									=  message.replace(" "       ,      ""							)
														__snake_case						:     List[Any]									=  message.replace("j"       ,      "i"							)

														__snake_case						:     Optional[Any]									=  np.empty((2, len(lowerCamelCase							))							)
														for letter_index in range(len(lowerCamelCase							)							):
																					__snake_case						:     List[Any]									=  self.letter_to_numbers(message[letter_index]							)

																					__snake_case						:     Any									=  numbers[0]
																					__snake_case						:     Dict									=  numbers[1]

														__snake_case						:     Optional[Any]									=  first_step.reshape(2 * len(lowerCamelCase							)							)
														__snake_case						:     str									=  ""
														for numbers_index in range(len(lowerCamelCase							)							):
																					__snake_case						:     str									=  int(second_step[numbers_index * 2]							)
																					__snake_case						:     List[Any]									=  int(second_step[(numbers_index * 2) + 1]							)
																					__snake_case						:     Optional[Any]									=  self.numbers_to_letter(lowerCamelCase       ,      lowerCamelCase							)
																					__snake_case						:     Union[str, Any]									=  encoded_message + letter

														return encoded_message






							def        __snake_case   (				self			:    Any       ,      lowerCamelCase			:    str							)      ->       str:
														__snake_case						:     Tuple									=  message.lower()
														message.replace(" "       ,      ""							)
														__snake_case						:     Dict									=  np.empty(2 * len(lowerCamelCase							)							)
														for letter_index in range(len(lowerCamelCase							)							):
																					__snake_case						:     str									=  self.letter_to_numbers(message[letter_index]							)
																					__snake_case						:     Dict									=  numbers[0]
																					__snake_case						:     Union[str, Any]									=  numbers[1]

														__snake_case						:     int									=  first_step.reshape((2, len(lowerCamelCase							))							)
														__snake_case						:     List[Any]									=  ""
														for numbers_index in range(len(lowerCamelCase							)							):
																					__snake_case						:     List[Any]									=  int(second_step[0, numbers_index]							)
																					__snake_case						:     Optional[Any]									=  int(second_step[1, numbers_index]							)
																					__snake_case						:     str									=  self.numbers_to_letter(lowerCamelCase       ,      lowerCamelCase							)
																					__snake_case						:     List[Any]									=  decoded_message + letter

														return decoded_message





import math

import tensorflow as tf
from packaging import version






def 	__lowerCamelCase						(							lowerCamelCase__		:						Any      ):





			'''simple docstring'''




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

			return x * cdf






def 	__lowerCamelCase						(							lowerCamelCase__		:						List[str]      ):





			'''simple docstring'''




			lowerCamelCase    		=  tf.convert_to_tensor(lowerCamelCase__      )
			lowerCamelCase    		=  tf.cast(math.pi  ,							x.dtype      )
			lowerCamelCase    		=  tf.cast(0.0_4_4_7_1_5  ,							x.dtype      )
			lowerCamelCase    		=  0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi      ) * (x + coeff * tf.pow(lowerCamelCase__  ,							3      ))      ))

			return x * cdf






def 	__lowerCamelCase						(							lowerCamelCase__		:						int      ):





			'''simple docstring'''




			lowerCamelCase    		=  tf.convert_to_tensor(lowerCamelCase__      )

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






def 	__lowerCamelCase						(							lowerCamelCase__		:						Union[str, Any]      ):





			'''simple docstring'''




			lowerCamelCase    		=  tf.convert_to_tensor(lowerCamelCase__      )
			lowerCamelCase    		=  tf.cast(0.0_4_4_7_1_5  ,							x.dtype      )
			lowerCamelCase    		=  tf.cast(0.7_9_7_8_8_4_5_6_0_8  ,							x.dtype      )

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






def 	__lowerCamelCase						(							lowerCamelCase__		:						Optional[int]      ):





			'''simple docstring'''




			lowerCamelCase    		=  tf.convert_to_tensor(lowerCamelCase__      )
			lowerCamelCase    		=  tf.cast(1.7_0_2  ,							x.dtype      )
			return x * tf.math.sigmoid(coeff * x      )






def 	__lowerCamelCase						(							lowerCamelCase__		:						Dict      ):





			'''simple docstring'''




			return tf.clip_by_value(_gelu(lowerCamelCase__      )  ,							-10  ,							10      )






def 	__lowerCamelCase						(							lowerCamelCase__		:						int  ,							lowerCamelCase__		:						Dict=-1      ):





			'''simple docstring'''




			lowerCamelCase		,		lowerCamelCase    		=  tf.split(lowerCamelCase__  ,							2  ,							axis=lowerCamelCase__      )
			return a * tf.math.sigmoid(lowerCamelCase__      )


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






		def 	__lowerCamelCase						(							lowerCamelCase__		:						Union[str, Any]      ):





					'''simple docstring'''




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

		UpperCAmelCase   :    Union[str, Any]     =		tf.keras.activations.gelu



		UpperCAmelCase   :    int     =		approximate_gelu_wrap
else:
		UpperCAmelCase   :    Dict     =		_gelu
		UpperCAmelCase   :    Dict     =		_gelu_new


UpperCAmelCase   :    List[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						(							lowerCamelCase__		:						Tuple      ):





			'''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()      )}'      )

