import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_layoutlm import LayoutLMTokenizer


__lowerCamelCase :     int          =  logging.get_logger(__name__)

__lowerCamelCase :     List[Any]          =  {'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

__lowerCamelCase :     List[str]          =  {
    '''vocab_file''': {
        '''microsoft/layoutlm-base-uncased''': (
            '''https://huggingface.co/microsoft/layoutlm-base-uncased/resolve/main/vocab.txt'''
        ),
        '''microsoft/layoutlm-large-uncased''': (
            '''https://huggingface.co/microsoft/layoutlm-large-uncased/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''microsoft/layoutlm-base-uncased''': (
            '''https://huggingface.co/microsoft/layoutlm-base-uncased/resolve/main/tokenizer.json'''
        ),
        '''microsoft/layoutlm-large-uncased''': (
            '''https://huggingface.co/microsoft/layoutlm-large-uncased/resolve/main/tokenizer.json'''
        ),
    },
}

__lowerCamelCase :     int          =  {
    '''microsoft/layoutlm-base-uncased''': 5_12,
    '''microsoft/layoutlm-large-uncased''': 5_12,
}

__lowerCamelCase :     List[str]          =  {
    '''microsoft/layoutlm-base-uncased''': {'''do_lower_case''': True},
    '''microsoft/layoutlm-large-uncased''': {'''do_lower_case''': True},
}






class 		a__						( A__ ):
					A     	=							VOCAB_FILES_NAMES
					A     	=							PRETRAINED_VOCAB_FILES_MAP
					A     	=							PRETRAINED_INIT_CONFIGURATION
					A     	=							PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
					A     	=							LayoutLMTokenizer

					def __init__(   self				:	List[str],_A				:	Optional[int]=None,_A				:	List[Any]=None,_A				:	int=True,_A				:	List[str]="[UNK]",_A				:	Union[str, Any]="[SEP]",_A				:	Optional[int]="[PAD]",_A				:	Optional[int]="[CLS]",_A				:	Tuple="[MASK]",_A				:	Any=True,_A				:	List[Any]=None,**_A				:	str,):







							"""simple docstring"""






							super().__init__(
							    _A,tokenizer_file=_A,do_lower_case=_A,unk_token=_A,sep_token=_A,pad_token=_A,cls_token=_A,mask_token=_A,tokenize_chinese_chars=_A,strip_accents=_A,**_A,)

							SCREAMING_SNAKE_CASE_  :		int    				=   json.loads(self.backend_tokenizer.normalizer.__getstate__()   )
							if (
							    normalizer_state.get("lowercase",_A   ) != do_lower_case
							    or normalizer_state.get("strip_accents",_A   ) != strip_accents
							    or normalizer_state.get("handle_chinese_chars",_A   ) != tokenize_chinese_chars
							):
									SCREAMING_SNAKE_CASE_  :		List[str]    				=   getattr(_A,normalizer_state.pop("type"   )   )
									SCREAMING_SNAKE_CASE_  :		int    				=   do_lower_case
									SCREAMING_SNAKE_CASE_  :		List[str]    				=   strip_accents
									SCREAMING_SNAKE_CASE_  :		Optional[Any]    				=   tokenize_chinese_chars
									SCREAMING_SNAKE_CASE_  :		Tuple    				=   normalizer_class(**_A   )

							SCREAMING_SNAKE_CASE_  :		List[Any]    				=   do_lower_case

					def     __UpperCamelCase       (   self				:	str,_A				:	Optional[int],_A				:	List[Any]=None   ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		List[str]    				=   [self.cls_token_id] + token_ids_a + [self.sep_token_id]

							if token_ids_a:
									output += token_ids_a + [self.sep_token_id]

							return output

					def     __UpperCamelCase       (   self				:	str,_A				:	List[int],_A				:	Optional[List[int]] = None   ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		str    				=   [self.sep_token_id]
							SCREAMING_SNAKE_CASE_  :		Optional[Any]    				=   [self.cls_token_id]
							if token_ids_a is None:
									return len(cls + token_ids_a + sep   ) * [0]
							return len(cls + token_ids_a + sep   ) * [0] + len(token_ids_a + sep   ) * [1]






					def     __UpperCamelCase       (   self				:	Any,_A				:	str,_A				:	Optional[str] = None   ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Tuple    				=   self._tokenizer.model.save(_A,name=_A   )
							return tuple(_A   )

__lowerCamelCase :     List[Any]          =  {hex(i)[2:]: i for i in range(16)}  # Use [:2] to strip off the leading '0x'




def 				_snake_case     (       lowerCAmelCase							:       str     ):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		Optional[Any]    				=   hex_string.strip().lower()
		if not hex_string:
				raise ValueError("Empty string was passed to the function"     )
		SCREAMING_SNAKE_CASE_  :		str    				=   hex_string[0] == "-"
		if is_negative:
				SCREAMING_SNAKE_CASE_  :		Optional[int]    				=   hex_string[1:]
		if not all(char in hex_table for char in hex_string     ):
				raise ValueError("Non-hexadecimal value was passed to the function"     )
		SCREAMING_SNAKE_CASE_  :		List[Any]    				=   0
		for char in hex_string:
				SCREAMING_SNAKE_CASE_  :		Tuple    				=   1_6 * decimal_number + hex_table[char]
		return -decimal_number if is_negative else decimal_number


if __name__ == "__main__":
		from doctest import testmod

		testmod()
