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


__lowerCAmelCase					:			Tuple			      =		logging.get_logger(__name__)

__lowerCAmelCase					:			Tuple			      =		{
    "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 						__lowerCAmelCase	(	lowerCAmelCase_      ):



      """simple docstring"""







      A__	:			List[Any]        =    '''markuplm'''




      def __init__(      self		:       Optional[int]				,       _snake_case		:       Optional[int]=3_0522				,       _snake_case		:       List[str]=768				,       _snake_case		:       Optional[int]=12				,       _snake_case		:       Tuple=12				,       _snake_case		:       str=3072				,       _snake_case		:       Union[str, Any]="gelu"				,       _snake_case		:       Any=0.1				,       _snake_case		:       Optional[Any]=0.1				,       _snake_case		:       Optional[Any]=512				,       _snake_case		:       str=2				,       _snake_case		:       List[str]=0.02				,       _snake_case		:       str=1E-1_2				,       _snake_case		:       Optional[Any]=0				,       _snake_case		:       Tuple=0				,       _snake_case		:       List[str]=2				,       _snake_case		:       Tuple=256				,       _snake_case		:       Optional[int]=1024				,       _snake_case		:       Optional[Any]=216				,       _snake_case		:       str=1001				,       _snake_case		:       int=32				,       _snake_case		:       int=50				,       _snake_case		:       Optional[Any]="absolute"				,       _snake_case		:       List[Any]=True				,       _snake_case		:       Dict=None				,       **_snake_case		:       List[Any]				,       ):
          super().__init__(
              pad_token_id=_snake_case				,       bos_token_id=_snake_case				,       eos_token_id=_snake_case				,       **_snake_case				,       )
          __lowercase		:			Any	    =       vocab_size
          __lowercase		:			List[str]	    =       hidden_size
          __lowercase		:			Union[str, Any]	    =       num_hidden_layers
          __lowercase		:			List[str]	    =       num_attention_heads
          __lowercase		:			Optional[Any]	    =       hidden_act
          __lowercase		:			Dict	    =       intermediate_size
          __lowercase		:			int	    =       hidden_dropout_prob
          __lowercase		:			Dict	    =       attention_probs_dropout_prob
          __lowercase		:			str	    =       max_position_embeddings
          __lowercase		:			List[Any]	    =       type_vocab_size
          __lowercase		:			int	    =       initializer_range
          __lowercase		:			List[Any]	    =       layer_norm_eps
          __lowercase		:			List[Any]	    =       position_embedding_type
          __lowercase		:			Optional[Any]	    =       use_cache
          __lowercase		:			Optional[Any]	    =       classifier_dropout
          # additional properties
          __lowercase		:			int	    =       max_depth
          __lowercase		:			Any	    =       max_xpath_tag_unit_embeddings
          __lowercase		:			str	    =       max_xpath_subs_unit_embeddings
          __lowercase		:			List[str]	    =       tag_pad_id
          __lowercase		:			Union[str, Any]	    =       subs_pad_id
          __lowercase		:			List[Any]	    =       xpath_unit_hidden_size




import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
 import torch

 from transformers.activations import gelu_new, gelu_python, get_activation


@require_torch
class 						__lowerCAmelCase	(	unittest.TestCase      ):



      """simple docstring"""







      def 		snake_case_			(      self		:       Optional[Any]				):
          __lowercase		:			Union[str, Any]	    =       torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]				)
          __lowercase		:			Any	    =       get_activation('''gelu'''				)
          self.assertTrue(torch.allclose(gelu_python(_snake_case				)				,       torch_builtin(_snake_case				)				)				)
          self.assertFalse(torch.allclose(gelu_python(_snake_case				)				,       gelu_new(_snake_case				)				)				)




      def 		snake_case_			(      self		:       Dict				):
          __lowercase		:			Any	    =       torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]				)
          __lowercase		:			List[str]	    =       get_activation('''gelu'''				)
          __lowercase		:			Optional[Any]	    =       get_activation('''gelu_10'''				)

          __lowercase		:			Tuple	    =       torch_builtin(_snake_case				)
          __lowercase		:			List[Any]	    =       geluaa(_snake_case				)

          __lowercase		:			Tuple	    =       torch.where(y_gelu_aa < 10.0				,       1				,       0				)

          self.assertTrue(torch.max(_snake_case				).item() == 10.0				)
          self.assertTrue(torch.allclose(y_gelu * clipped_mask				,       y_gelu_aa * clipped_mask				)				)




      def 		snake_case_			(      self		:       Any				):
          get_activation('''gelu'''				)
          get_activation('''gelu_10'''				)
          get_activation('''gelu_fast'''				)
          get_activation('''gelu_new'''				)
          get_activation('''gelu_python'''				)
          get_activation('''gelu_pytorch_tanh'''				)
          get_activation('''linear'''				)
          get_activation('''mish'''				)
          get_activation('''quick_gelu'''				)
          get_activation('''relu'''				)
          get_activation('''sigmoid'''				)
          get_activation('''silu'''				)
          get_activation('''swish'''				)
          get_activation('''tanh'''				)
          with self.assertRaises(_snake_case				):
              get_activation('''bogus'''				)
          with self.assertRaises(_snake_case				):
              get_activation(_snake_case				)




      def 		snake_case_			(      self		:       Dict				):
          __lowercase		:			Union[str, Any]	    =       get_activation('''gelu'''				)
          __lowercase		:			List[str]	    =       1
          __lowercase		:			Union[str, Any]	    =       get_activation('''gelu'''				)
          self.assertEqual(acta.a				,       1				)
          with self.assertRaises(_snake_case				):
              __lowercase		:			Tuple	    =       acta.a


