


import math

import tensorflow as tf
from packaging import version






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		List[Any]	):





			"""simple docstring"""




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

			return x * cdf






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		List[str]	):





			"""simple docstring"""




			UpperCamelCase         =					tf.convert_to_tensor(UpperCamelCase__	)
			UpperCamelCase         =					tf.cast(math.pi       ,  x.dtype	)
			UpperCamelCase         =					tf.cast(0.04_4715       ,  x.dtype	)
			UpperCamelCase         =					0.5 * (1.0 + tf.tanh(tf.sqrt(2.0 / pi	) * (x + coeff * tf.pow(UpperCamelCase__       ,  3	))	))

			return x * cdf






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		List[Any]	):





			"""simple docstring"""




			UpperCamelCase         =					tf.convert_to_tensor(UpperCamelCase__	)

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






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		Optional[Any]	):





			"""simple docstring"""




			UpperCamelCase         =					tf.convert_to_tensor(UpperCamelCase__	)
			UpperCamelCase         =					tf.cast(0.04_4715       ,  x.dtype	)
			UpperCamelCase         =					tf.cast(0.79_7884_5608       ,  x.dtype	)

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






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		Dict	):





			"""simple docstring"""




			UpperCamelCase         =					tf.convert_to_tensor(UpperCamelCase__	)
			UpperCamelCase         =					tf.cast(1.702       ,  x.dtype	)
			return x * tf.math.sigmoid(coeff * x	)






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		Dict	):





			"""simple docstring"""




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






def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		Tuple       ,  SCREAMING_SNAKE_CASE_   :		Tuple=-1	):





			"""simple docstring"""




			UpperCamelCase         =					tf.split(UpperCamelCase__       ,  2       ,  axis=UpperCamelCase__	)
			return a * tf.math.sigmoid(UpperCamelCase__	)


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






			def 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		List[str]	):





						"""simple docstring"""




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

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


__snake_case     :   Union[str, Any]            =   {
    '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 							_lowercase    (		SCREAMING_SNAKE_CASE_   :		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()	)}'	)








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


__snake_case            =   logging.get_logger(__name__)

__snake_case            =   {
    "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json",
    "microsoft/markuplm-large": "https://huggingface.co/microsoft/markuplm-large/resolve/main/config.json",
}




class    UpperCAmelCase					(       __snake_case    ):
			lowercase						= """markuplm"""




			def __init__(						self							:		Optional[Any]       ,       __magic_name__							:		List[Any]=3_0_5_2_2       ,       __magic_name__							:		int=7_6_8       ,       __magic_name__							:		List[Any]=1_2       ,       __magic_name__							:		List[Any]=1_2       ,       __magic_name__							:		str=3_0_7_2       ,       __magic_name__							:		Optional[int]="gelu"       ,       __magic_name__							:		Dict=0.1       ,       __magic_name__							:		Optional[int]=0.1       ,       __magic_name__							:		Any=5_1_2       ,       __magic_name__							:		List[str]=2       ,       __magic_name__							:		Dict=0.02       ,       __magic_name__							:		List[str]=1e-12       ,       __magic_name__							:		str=0       ,       __magic_name__							:		List[str]=0       ,       __magic_name__							:		Optional[Any]=2       ,       __magic_name__							:		Dict=2_5_6       ,       __magic_name__							:		Tuple=1_0_2_4       ,       __magic_name__							:		Any=2_1_6       ,       __magic_name__							:		str=1_0_0_1       ,       __magic_name__							:		Dict=3_2       ,       __magic_name__							:		Optional[int]=5_0       ,       __magic_name__							:		List[Any]="absolute"       ,       __magic_name__							:		Any=True       ,       __magic_name__							:		Optional[Any]=None       ,       **__magic_name__							:		List[str]       ,       ):







						"""simple docstring"""







						super().__init__(
						    pad_token_id=__magic_name__       ,       bos_token_id=__magic_name__       ,       eos_token_id=__magic_name__       ,       **__magic_name__       ,       )
						UpperCamelCase         =					vocab_size
						UpperCamelCase         =					hidden_size
						UpperCamelCase         =					num_hidden_layers
						UpperCamelCase         =					num_attention_heads
						UpperCamelCase         =					hidden_act
						UpperCamelCase         =					intermediate_size
						UpperCamelCase         =					hidden_dropout_prob
						UpperCamelCase         =					attention_probs_dropout_prob
						UpperCamelCase         =					max_position_embeddings
						UpperCamelCase         =					type_vocab_size
						UpperCamelCase         =					initializer_range
						UpperCamelCase         =					layer_norm_eps
						UpperCamelCase         =					position_embedding_type
						UpperCamelCase         =					use_cache
						UpperCamelCase         =					classifier_dropout
						# additional properties
						UpperCamelCase         =					max_depth
						UpperCamelCase         =					max_xpath_tag_unit_embeddings
						UpperCamelCase         =					max_xpath_subs_unit_embeddings
						UpperCamelCase         =					tag_pad_id
						UpperCamelCase         =					subs_pad_id
						UpperCamelCase         =					xpath_unit_hidden_size




