



'''simple docstring'''

import importlib.metadata
import operator
import re
import sys
from typing import Optional

from packaging import version


snake_case_			=     {
    """<""": operator.lt,
    """<=""": operator.le,
    """==""": operator.eq,
    """!=""": operator.ne,
    """>=""": operator.ge,
    """>""": operator.gt,
}






def       __lowercase  (_SCREAMING_SNAKE_CASE      :Optional[int]    ,	_SCREAMING_SNAKE_CASE      :Dict    ,	_SCREAMING_SNAKE_CASE      :Optional[int]    ,	_SCREAMING_SNAKE_CASE      :str    ,	_SCREAMING_SNAKE_CASE      :Optional[Any]    ,	_SCREAMING_SNAKE_CASE      :List[Any]       ):
				if got_ver is None or want_ver is None:
								raise ValueError(
								    F'''Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider'''
								    F''' reinstalling {pkg}.'''       )
				if not ops[op](version.parse(_SCREAMING_SNAKE_CASE       )    ,	version.parse(_SCREAMING_SNAKE_CASE       )       ):
								raise ImportError(
								    F'''{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}'''       )






def       __lowercase  (_SCREAMING_SNAKE_CASE      :str    ,	_SCREAMING_SNAKE_CASE      :Optional[str] = None       ):
				SCREAMING_SNAKE_CASE  :						Any      					= F'''\n{hint}''' if hint is not None else ''''''

				# non-versioned check
				if re.match(R'''^[\w_\-\d]+$'''    ,	_SCREAMING_SNAKE_CASE       ):
								SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						List[Any]      					= requirement, None, None
				else:
								SCREAMING_SNAKE_CASE  :						int      					= re.findall(R'''^([^!=<>\s]+)([\s!=<>]{1,2}.+)'''    ,	_SCREAMING_SNAKE_CASE       )
								if not match:
												raise ValueError(
												    '''requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but'''
												    F''' got {requirement}'''       )
								SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Optional[int]      					= match[0]
								SCREAMING_SNAKE_CASE  :						Optional[Any]      					= want_full.split(''','''       )  # there could be multiple requirements
								SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= {}
								for w in want_range:
												SCREAMING_SNAKE_CASE  :						Optional[int]      					= re.findall(R'''^([\s!=<>]{1,2})(.+)'''    ,	_SCREAMING_SNAKE_CASE       )
												if not match:
																raise ValueError(
																    '''requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,'''
																    F''' but got {requirement}'''       )
												SCREAMING_SNAKE_CASE					,					SCREAMING_SNAKE_CASE  :						Tuple      					= match[0]
												SCREAMING_SNAKE_CASE  :						Any      					= want_ver
												if op not in ops:
																raise ValueError(F'''{requirement}: need one of {list(ops.keys()       )}, but got {op}'''       )

    # special case
				if pkg == "python":
								SCREAMING_SNAKE_CASE  :						Optional[int]      					= '''.'''.join([str(_SCREAMING_SNAKE_CASE       ) for x in sys.version_info[:3]]       )
								for op, want_ver in wanted.items():
												_compare_versions(_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE       )
								return

				# check if any version is installed
				try:
								SCREAMING_SNAKE_CASE  :						Union[str, Any]      					= importlib.metadata.version(_SCREAMING_SNAKE_CASE       )
				except importlib.metadata.PackageNotFoundError:
								raise importlib.metadata.PackageNotFoundError(
								    F'''The \'{requirement}\' distribution was not found and is required by this application. {hint}'''       )

				# check that the right version is installed if version number or a range was provided
				if want_ver is not None:
								for op, want_ver in wanted.items():
												_compare_versions(_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE       )






def       __lowercase  (_SCREAMING_SNAKE_CASE      :str       ):
				SCREAMING_SNAKE_CASE  :						Optional[Any]      					= '''Try: pip install transformers -U or pip install -e \'.[dev]\' if you\'re working with git main'''
				return require_version(_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE       )









'''simple docstring'''

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 	a__     (				_lowercase	):
	__magic_name__		:    List[Any]	    =     "markuplm"


	def __init__(self : List[Any],					__UpperCAmelCase : int=30522,					__UpperCAmelCase : Tuple=768,					__UpperCAmelCase : str=12,					__UpperCAmelCase : List[Any]=12,					__UpperCAmelCase : Tuple=3072,					__UpperCAmelCase : Union[str, Any]="gelu",					__UpperCAmelCase : Union[str, Any]=0.1,					__UpperCAmelCase : str=0.1,					__UpperCAmelCase : Union[str, Any]=512,					__UpperCAmelCase : Dict=2,					__UpperCAmelCase : int=0.02,					__UpperCAmelCase : Optional[Any]=1e-12,					__UpperCAmelCase : Union[str, Any]=0,					__UpperCAmelCase : Optional[Any]=0,					__UpperCAmelCase : Union[str, Any]=2,					__UpperCAmelCase : int=256,					__UpperCAmelCase : Tuple=1024,					__UpperCAmelCase : Optional[Any]=216,					__UpperCAmelCase : str=1001,					__UpperCAmelCase : Optional[Any]=32,					__UpperCAmelCase : Dict=50,					__UpperCAmelCase : Union[str, Any]="absolute",					__UpperCAmelCase : Tuple=True,					__UpperCAmelCase : List[str]=None,					**__UpperCAmelCase : Union[str, Any],					)     ->			Union[str, Any]:

					"""simple docstring"""

					super().__init__(
					    pad_token_id=__UpperCAmelCase,					bos_token_id=__UpperCAmelCase,					eos_token_id=__UpperCAmelCase,					**__UpperCAmelCase,					)
					SCREAMING_SNAKE_CASE  :						List[Any]      					= vocab_size
					SCREAMING_SNAKE_CASE  :						Dict      					= hidden_size
					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= num_hidden_layers
					SCREAMING_SNAKE_CASE  :						Dict      					= num_attention_heads
					SCREAMING_SNAKE_CASE  :						Any      					= hidden_act
					SCREAMING_SNAKE_CASE  :						Tuple      					= intermediate_size
					SCREAMING_SNAKE_CASE  :						Tuple      					= hidden_dropout_prob
					SCREAMING_SNAKE_CASE  :						List[str]      					= attention_probs_dropout_prob
					SCREAMING_SNAKE_CASE  :						List[str]      					= max_position_embeddings
					SCREAMING_SNAKE_CASE  :						Dict      					= type_vocab_size
					SCREAMING_SNAKE_CASE  :						Tuple      					= initializer_range
					SCREAMING_SNAKE_CASE  :						Optional[Any]      					= layer_norm_eps
					SCREAMING_SNAKE_CASE  :						int      					= position_embedding_type
					SCREAMING_SNAKE_CASE  :						List[Any]      					= use_cache
					SCREAMING_SNAKE_CASE  :						int      					= classifier_dropout
					# additional properties
					SCREAMING_SNAKE_CASE  :						List[Any]      					= max_depth
					SCREAMING_SNAKE_CASE  :						Any      					= max_xpath_tag_unit_embeddings
					SCREAMING_SNAKE_CASE  :						int      					= max_xpath_subs_unit_embeddings
					SCREAMING_SNAKE_CASE  :						Dict      					= tag_pad_id
					SCREAMING_SNAKE_CASE  :						Optional[int]      					= subs_pad_id
					SCREAMING_SNAKE_CASE  :						int      					= xpath_unit_hidden_size




