


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


_A		:					Optional[Any]          =							logging.get_logger(__name__)

_A		:					Any          =							{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

_A		:					Optional[int]          =							{
    '''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'''
        ),
    },
}

_A		:					int          =							{
    '''microsoft/layoutlm-base-uncased''': 512,
    '''microsoft/layoutlm-large-uncased''': 512,
}

_A		:					str          =							{
    '''microsoft/layoutlm-base-uncased''': {'''do_lower_case''': True},
    '''microsoft/layoutlm-large-uncased''': {'''do_lower_case''': True},
}



class 							a       (      _UpperCAmelCase ):
     UpperCAmelCase__			:	Tuple       =						VOCAB_FILES_NAMES
     UpperCAmelCase__			:	str       =						PRETRAINED_VOCAB_FILES_MAP
     UpperCAmelCase__			:	Optional[Any]       =						PRETRAINED_INIT_CONFIGURATION
     UpperCAmelCase__			:	List[str]       =						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     UpperCAmelCase__			:	Optional[Any]       =						LayoutLMTokenizer





     def __init__(     self       :					str     ,						SCREAMING_SNAKE_CASE_       :					List[Any]=None     ,						SCREAMING_SNAKE_CASE_       :					List[Any]=None     ,						SCREAMING_SNAKE_CASE_       :					Any=True     ,						SCREAMING_SNAKE_CASE_       :					str="[UNK]"     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]="[SEP]"     ,						SCREAMING_SNAKE_CASE_       :					Union[str, Any]="[PAD]"     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]="[CLS]"     ,						SCREAMING_SNAKE_CASE_       :					Any="[MASK]"     ,						SCREAMING_SNAKE_CASE_       :					Optional[int]=True     ,						SCREAMING_SNAKE_CASE_       :					Any=None     ,						**SCREAMING_SNAKE_CASE_       :					List[str]     ,						):
        super().__init__(
            SCREAMING_SNAKE_CASE_     ,						tokenizer_file=SCREAMING_SNAKE_CASE_     ,						do_lower_case=SCREAMING_SNAKE_CASE_     ,						unk_token=SCREAMING_SNAKE_CASE_     ,						sep_token=SCREAMING_SNAKE_CASE_     ,						pad_token=SCREAMING_SNAKE_CASE_     ,						cls_token=SCREAMING_SNAKE_CASE_     ,						mask_token=SCREAMING_SNAKE_CASE_     ,						tokenize_chinese_chars=SCREAMING_SNAKE_CASE_     ,						strip_accents=SCREAMING_SNAKE_CASE_     ,						**SCREAMING_SNAKE_CASE_     ,						)

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

        __lowerCamelCase:					List[str]	 =						do_lower_case





     def 			SCREAMING_SNAKE_CASE__							(     self       :					List[Any]     ,						SCREAMING_SNAKE_CASE_       :					Dict     ,						SCREAMING_SNAKE_CASE_       :					Tuple=None				):
        __lowerCamelCase:					Union[str, Any]	 =						[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 			SCREAMING_SNAKE_CASE__							(     self       :					Optional[int]     ,						SCREAMING_SNAKE_CASE_       :					List[int]     ,						SCREAMING_SNAKE_CASE_       :					Optional[List[int]] = None				):
        __lowerCamelCase:					int	 =						[self.sep_token_id]
        __lowerCamelCase:					Union[str, 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 			SCREAMING_SNAKE_CASE__							(     self       :					Union[str, Any]     ,						SCREAMING_SNAKE_CASE_       :					str     ,						SCREAMING_SNAKE_CASE_       :					Optional[str] = None				):
        __lowerCamelCase:					List[Any]	 =						self._tokenizer.model.save(SCREAMING_SNAKE_CASE_     ,						name=SCREAMING_SNAKE_CASE_				)
        return tuple(SCREAMING_SNAKE_CASE_				)






import sys



def      __lowerCAmelCase    (				snake_case						:     int    ,   snake_case						:     list[int]			)							->				int:
   if not numbers:
      return 0
   if target == 0 and target in numbers:
      return 0
   if not isinstance(snake_case    ,   (list, tuple)			) or not all(
       isinstance(snake_case    ,   snake_case			) for number in numbers			):
      raise ValueError("""numbers must be an iterable of integers"""			)

   __lowerCamelCase:					Union[str, Any]	 =						0
   __lowerCamelCase:					str	 =						sys.maxsize

   while right < len(snake_case			):
      curr_sum += numbers[right]
      while curr_sum >= target and left <= right:
         __lowerCamelCase:					str	 =						min(snake_case    ,   right - left + 1			)
         curr_sum -= numbers[left]
         left += 1
      right += 1

   return 0 if min_len == sys.maxsize else min_len


