



from __future__ import annotations

from typing import Any



class    _lowerCAmelCase    :





		"""simple docstring"""






		def __init__(					self							,    _lowercase = 6   ) ->						None:







								'''simple docstring'''

								snake_case_   : Union[str, Any]						=			None
								snake_case_   : Optional[Any]						=			None
								self.create_linked_list(A_   )





		def    UpperCAmelCase__							(					self							,    _lowercase   ) ->						None:







								'''simple docstring'''

								snake_case_   : int						=			Node()
								snake_case_   : List[str]						=			current_node
								snake_case_   : List[str]						=			current_node
								snake_case_   : Union[str, Any]						=			current_node
								for _ in range(1							,    A_   ):
														snake_case_   : Dict						=			Node()
														snake_case_   : Any						=			current_node
														snake_case_   : Dict						=			previous_node
														snake_case_   : str						=			current_node
								snake_case_   : str						=			self.front
								snake_case_   : str						=			previous_node





		def    UpperCAmelCase__							(					self   ) ->						bool:







								'''simple docstring'''

								return (
								    self.front == self.rear
								    and self.front is not None
								    and self.front.data is None
								)





		def    UpperCAmelCase__							(					self   ) ->						Any | None:







								'''simple docstring'''

								self.check_can_perform_operation()
								return self.front.data if self.front else None





		def    UpperCAmelCase__							(					self							,    _lowercase   ) ->						None:







								'''simple docstring'''

								if self.rear is None:
														return

								self.check_is_full()
								if not self.is_empty():
														snake_case_   : int						=			self.rear.next
								if self.rear:
														snake_case_   : Optional[int]						=			data





		def    UpperCAmelCase__							(					self   ) ->						Any:







								'''simple docstring'''

								self.check_can_perform_operation()
								if self.rear is None or self.front is None:
														return None
								if self.front == self.rear:
														snake_case_   : str						=			self.front.data
														snake_case_   : Union[str, Any]						=			None
														return data

								snake_case_   : Any						=			self.front
								snake_case_   : Optional[int]						=			old_front.next
								snake_case_   : List[str]						=			old_front.data
								snake_case_   : Tuple						=			None
								return data





		def    UpperCAmelCase__							(					self   ) ->						None:







								'''simple docstring'''

								if self.is_empty():
														raise Exception("""Empty Queue"""   )





		def    UpperCAmelCase__							(					self   ) ->						None:







								'''simple docstring'''

								if self.rear and self.rear.next == self.front:
														raise Exception("""Full Queue"""   )




class    _lowerCAmelCase    :





		"""simple docstring"""






		def __init__(					self   ) ->						None:







								'''simple docstring'''

								snake_case_   : str						=			None
								snake_case_   : Tuple						=			None
								snake_case_   : str						=			None


if __name__ == "__main__":
					import doctest

					doctest.testmod()






"""simple docstring"""





import math

import tensorflow as tf
from packaging import version
def 	__lowerCAmelCase						(		__UpperCamelCase      :			List[Any]    ):


						'''simple docstring'''






						snake_case_   : int						=			tf.convert_to_tensor(__UpperCamelCase    )
						snake_case_   : int						=			0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0    )					, x.dtype    )    ))

						return x * cdf
def 	__lowerCAmelCase						(		__UpperCamelCase      :			List[str]    ):


						'''simple docstring'''






						snake_case_   : int						=			tf.convert_to_tensor(__UpperCamelCase    )
						snake_case_   : List[Any]						=			tf.cast(math.pi					, x.dtype    )
						snake_case_   : int						=			tf.cast(0.044_715					, x.dtype    )
						snake_case_   : Optional[int]						=			0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi    ) * (x + coeff * tf.pow(__UpperCamelCase					, 3    ))    ))

						return x * cdf
def 	__lowerCAmelCase						(		__UpperCamelCase      :			str    ):


						'''simple docstring'''






						snake_case_   : Optional[Any]						=			tf.convert_to_tensor(__UpperCamelCase    )

						return x * tf.tanh(tf.math.softplus(__UpperCamelCase    )    )
def 	__lowerCAmelCase						(		__UpperCamelCase      :			Any    ):


						'''simple docstring'''






						snake_case_   : str						=			tf.convert_to_tensor(__UpperCamelCase    )
						snake_case_   : int						=			tf.cast(0.044_715					, x.dtype    )
						snake_case_   : Optional[int]						=			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						(		__UpperCamelCase      :			List[str]    ):


						'''simple docstring'''






						snake_case_   : Tuple						=			tf.convert_to_tensor(__UpperCamelCase    )
						snake_case_   : str						=			tf.cast(1.702					, x.dtype    )
						return x * tf.math.sigmoid(coeff * x    )
def 	__lowerCAmelCase						(		__UpperCamelCase      :			int    ):


						'''simple docstring'''






						return tf.clip_by_value(_gelu(__UpperCamelCase    )					, -1_0					, 1_0    )
def 	__lowerCAmelCase						(		__UpperCamelCase      :			Optional[int]					, __UpperCamelCase      :			List[str]=-1    ):


						'''simple docstring'''






						snake_case_			,		snake_case_   : List[Any]						=			tf.split(__UpperCamelCase					, 2					, axis=__UpperCamelCase    )
						return a * tf.math.sigmoid(__UpperCamelCase    )


if version.parse(tf.version.VERSION) >= version.parse('''2.4'''):
					def 	__lowerCAmelCase						(		__UpperCamelCase      :			List[Any]    ):


											'''simple docstring'''






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

					__lowerCAmelCase       :					int      					=					tf.keras.activations.gelu






					__lowerCAmelCase       :					Optional[Any]      					=					approximate_gelu_wrap
else:
					__lowerCAmelCase       :					List[Any]      					=					_gelu
					__lowerCAmelCase       :					Any      					=					_gelu_new


__lowerCAmelCase       :					Dict      					=					{
    '''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						(		__UpperCamelCase      :			Any    ):


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

