



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


UpperCAmelCase :				Optional[int]							=logging.get_logger(__name__)

UpperCAmelCase :				List[str]							={"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}

UpperCAmelCase :				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"""
        ),
    },
}

UpperCAmelCase :				str							={
    """microsoft/layoutlm-base-uncased""": 512,
    """microsoft/layoutlm-large-uncased""": 512,
}

UpperCAmelCase :				Any							={
    """microsoft/layoutlm-base-uncased""": {"""do_lower_case""": True},
    """microsoft/layoutlm-large-uncased""": {"""do_lower_case""": True},
}


class    _lowercase (a_   ):
				'''simple docstring'''







				lowercase__     =    VOCAB_FILES_NAMES
				lowercase__     =    PRETRAINED_VOCAB_FILES_MAP
				lowercase__     =    PRETRAINED_INIT_CONFIGURATION
				lowercase__     =    PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
				lowercase__     =    LayoutLMTokenizer

				def __init__(			self  ,			snake_case__=None  ,			snake_case__=None  ,			snake_case__=True  ,			snake_case__="[UNK]"  ,			snake_case__="[SEP]"  ,			snake_case__="[PAD]"  ,			snake_case__="[CLS]"  ,			snake_case__="[MASK]"  ,			snake_case__=True  ,			snake_case__=None  ,			**snake_case__  ,			):

									'''simple docstring'''


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

									UpperCamelCase_			= json.loads(self.backend_tokenizer.normalizer.__getstate__()     )
									if (
									    normalizer_state.get("lowercase"  ,			snake_case__     ) != do_lower_case
									    or normalizer_state.get("strip_accents"  ,			snake_case__     ) != strip_accents
									    or normalizer_state.get("handle_chinese_chars"  ,			snake_case__     ) != tokenize_chinese_chars
									):
														UpperCamelCase_			= getattr(snake_case__  ,			normalizer_state.pop("type"     )     )
														UpperCamelCase_			= do_lower_case
														UpperCamelCase_			= strip_accents
														UpperCamelCase_			= tokenize_chinese_chars
														UpperCamelCase_			= normalizer_class(**snake_case__     )

									UpperCamelCase_			= do_lower_case

				def    _lowerCamelCase       (			self  ,			snake_case__  ,			snake_case__=None     ):

									'''simple docstring'''


									UpperCamelCase_			= [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    _lowerCamelCase       (			self  ,			snake_case__  ,			snake_case__ = None     ):

									'''simple docstring'''


									UpperCamelCase_			= [self.sep_token_id]
									UpperCamelCase_			= [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    _lowerCamelCase       (			self  ,			snake_case__  ,			snake_case__ = None     ):

									'''simple docstring'''


									UpperCamelCase_			= self._tokenizer.model.save(snake_case__  ,			name=snake_case__     )
									return tuple(snake_case__     )


'''simple docstring'''





import math
from timeit import timeit

def   A			(							A_				:       int							):
						snake_case							:  List[str]			=     0
						snake_case							:  Any			=     abs(A_							)
						while True:
												snake_case							:  List[Any]			=     n // 10
												digits += 1
												if n == 0:
																		break
						return digits

def   A			(							A_				:       int							):
						return 1 if n == 0 else math.floor(math.log(abs(A_							)     ,				10							) + 1							)

def   A			(							A_				:       int							):
						return len(str(abs(A_							)							)							)

def   A			(							):
						from collections.abc import Callable

						def benchmark_a_function(A_				:       Callable     ,				A_				:       int							) -> None:
												snake_case							:  Optional[int]			=     F"""{func.__name__}({value})"""
												snake_case							:  Optional[int]			=     timeit(F"""__main__.{call}"""     ,				setup='''import __main__'''							)
												print(F"""{call}: {func(A_							)} -- {timing} seconds"""							)

						for value in (262144, 1125899906842624, 1267650600228229401496703205376):
												for func in (num_digits, num_digits_fast, num_digits_faster):
																		benchmark_a_function(A_     ,				A_							)
												print()


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						benchmark()

