



import math

import tensorflow as tf
from packaging import version







def       lowerCAmelCase_     (lowerCAmelCase__:						Tuple   ):





			"""simple docstring"""


			UpperCAmelCase_:						Optional[int]					=			tf.convert_to_tensor(__a   )
			UpperCAmelCase_:						Any					=			0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0   )						,		x.dtype   )   ))

			return x * cdf







def       lowerCAmelCase_     (lowerCAmelCase__:						Union[str, Any]   ):





			"""simple docstring"""


			UpperCAmelCase_:						Any					=			tf.convert_to_tensor(__a   )
			UpperCAmelCase_:						Optional[Any]					=			tf.cast(math.pi						,		x.dtype   )
			UpperCAmelCase_:						Any					=			tf.cast(0.044715						,		x.dtype   )
			UpperCAmelCase_:						str					=			0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi   ) * (x + coeff * tf.pow(__a						,		3   ))   ))

			return x * cdf







def       lowerCAmelCase_     (lowerCAmelCase__:						List[str]   ):





			"""simple docstring"""


			UpperCAmelCase_:						List[Any]					=			tf.convert_to_tensor(__a   )

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







def       lowerCAmelCase_     (lowerCAmelCase__:						Optional[int]   ):





			"""simple docstring"""


			UpperCAmelCase_:						Any					=			tf.convert_to_tensor(__a   )
			UpperCAmelCase_:						int					=			tf.cast(0.044715						,		x.dtype   )
			UpperCAmelCase_:						str					=			tf.cast(0.7978845608						,		x.dtype   )

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







def       lowerCAmelCase_     (lowerCAmelCase__:						str   ):





			"""simple docstring"""


			UpperCAmelCase_:						Union[str, Any]					=			tf.convert_to_tensor(__a   )
			UpperCAmelCase_:						List[str]					=			tf.cast(1.702						,		x.dtype   )
			return x * tf.math.sigmoid(coeff * x   )







def       lowerCAmelCase_     (lowerCAmelCase__:						List[str]   ):





			"""simple docstring"""


			return tf.clip_by_value(_gelu(__a   )						,		-1_0						,		1_0   )







def       lowerCAmelCase_     (lowerCAmelCase__:						Union[str, Any]						,		lowerCAmelCase__:						Optional[Any]=-1   ):





			"""simple docstring"""


			UpperCAmelCase_:						int					=			tf.split(__a						,		2						,		axis=__a   )
			return a * tf.math.sigmoid(__a   )


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







	def       lowerCAmelCase_     (lowerCAmelCase__:						List[str]   ):





				"""simple docstring"""


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

	a	:   List[Any]       			=       tf.keras.activations.gelu

	a	:   Optional[int]       			=       approximate_gelu_wrap
else:
	a	:   Optional[int]       			=       _gelu
	a	:   Tuple       			=       _gelu_new


a	:   Tuple       			=       {
    '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__:						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()   )}'   )








'''simple docstring'''







import warnings

from ...utils import logging
from .image_processing_beit import BeitImageProcessor


__lowerCAmelCase         =    logging.get_logger(__name__)







class UpperCAmelCase__	( lowercase__	):





  """simple docstring"""

  def __init__(		self      :     int							,*_a      :     Optional[int]							,**_a      :     str       ):


     '''simple docstring'''






     warnings.warn(
         'The class BeitFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please'
         ' use BeitImageProcessor instead.'							,_a							,)
     super().__init__(*_a							,**_a       )



