



'''simple docstring'''

from ...configuration_utils import PretrainedConfig
from ...utils import logging


a							   =				logging.get_logger(__name__)

a							   =				{
    'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json',
    'studio-ousia/luke-large': 'https://huggingface.co/studio-ousia/luke-large/resolve/main/config.json',
}






class 						a_		(     snake_case    ):
							UpperCAmelCase			:		List[str]        =				"""luke"""


							def __init__(				self   :						Any      ,						a_   :						Union[str, Any]=5_0_2_6_7      ,						a_   :						List[str]=5_0_0_0_0_0      ,						a_   :						List[Any]=7_6_8      ,						a_   :						int=2_5_6      ,						a_   :						Optional[Any]=1_2      ,						a_   :						Optional[int]=1_2      ,						a_   :						Optional[Any]=3_0_7_2      ,						a_   :						List[Any]="gelu"      ,						a_   :						Optional[int]=0.1      ,						a_   :						List[Any]=0.1      ,						a_   :						Optional[int]=5_1_2      ,						a_   :						List[Any]=2      ,						a_   :						List[Any]=0.0_2      ,						a_   :						List[Any]=1E-1_2      ,						a_   :						Any=True      ,						a_   :						int=None      ,						a_   :						int=1      ,						a_   :						Any=0      ,						a_   :						Union[str, Any]=2      ,						**a_   :						str      ,						)			->					List[str]:
										super().__init__(pad_token_id=a_      ,						bos_token_id=a_      ,						eos_token_id=a_      ,						**a_			)

										snake_case:    Tuple      							=vocab_size
										snake_case:    Union[str, Any]      							=entity_vocab_size
										snake_case:    Any      							=hidden_size
										snake_case:    List[str]      							=entity_emb_size
										snake_case:    List[str]      							=num_hidden_layers
										snake_case:    Optional[Any]      							=num_attention_heads
										snake_case:    Union[str, Any]      							=hidden_act
										snake_case:    List[Any]      							=intermediate_size
										snake_case:    Optional[Any]      							=hidden_dropout_prob
										snake_case:    str      							=attention_probs_dropout_prob
										snake_case:    Union[str, Any]      							=max_position_embeddings
										snake_case:    str      							=type_vocab_size
										snake_case:    List[str]      							=initializer_range
										snake_case:    Tuple      							=layer_norm_eps
										snake_case:    List[Any]      							=use_entity_aware_attention
										snake_case:    Union[str, Any]      							=classifier_dropout









'''simple docstring'''

import math

import tensorflow as tf
from packaging import version







def a_     (    __UpperCAmelCase					)				->					Optional[Any]:





			"""simple docstring"""







			snake_case:    str      							=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 a_     (    __UpperCAmelCase					)				->					Dict:





			"""simple docstring"""







			snake_case:    Optional[int]      							=tf.convert_to_tensor(__UpperCAmelCase					)
			snake_case:    Tuple      							=tf.cast(math.pi				,							x.dtype					)
			snake_case:    Dict      							=tf.cast(0.04_4715				,							x.dtype					)
			snake_case:    List[str]      							=0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi					) * (x + coeff * tf.pow(__UpperCAmelCase				,							3					))					))

			return x * cdf







def a_     (    __UpperCAmelCase					)				->					Tuple:





			"""simple docstring"""







			snake_case:    Optional[int]      							=tf.convert_to_tensor(__UpperCAmelCase					)

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







def a_     (    __UpperCAmelCase					)				->					Dict:





			"""simple docstring"""







			snake_case:    List[str]      							=tf.convert_to_tensor(__UpperCAmelCase					)
			snake_case:    Dict      							=tf.cast(0.04_4715				,							x.dtype					)
			snake_case:    List[str]      							=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_     (    __UpperCAmelCase					)				->					Optional[Any]:





			"""simple docstring"""







			snake_case:    Union[str, Any]      							=tf.convert_to_tensor(__UpperCAmelCase					)
			snake_case:    Tuple      							=tf.cast(1.702				,							x.dtype					)
			return x * tf.math.sigmoid(coeff * x					)







def a_     (    __UpperCAmelCase					)				->					int:





			"""simple docstring"""







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







def a_     (    __UpperCAmelCase				,							__UpperCAmelCase=-1					)				->					List[str]:





			"""simple docstring"""







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


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







	def a_     (    __UpperCAmelCase					)				->					int:





				"""simple docstring"""







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

	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_     (    __UpperCAmelCase					)				->					Dict:





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




