





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


__lowercase				    =      logging.get_logger(__name__)

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

__lowercase				    =      {
    '''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'''
        ),
    },
}

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

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

class 	__snake_case					(      _UpperCAmelCase ):






    '''simple docstring'''
    _lowerCAmelCase  =						VOCAB_FILES_NAMES
    _lowerCAmelCase  =						PRETRAINED_VOCAB_FILES_MAP
    _lowerCAmelCase  =						PRETRAINED_INIT_CONFIGURATION
    _lowerCAmelCase  =						PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    _lowerCAmelCase  =						LayoutLMTokenizer





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

      """simple docstring"""





      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								=					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								=					getattr(SCREAMING_SNAKE_CASE_      ,    normalizer_state.pop('''type'''				)				)
        __lowerCAmelCase								=					do_lower_case
        __lowerCAmelCase								=					strip_accents
        __lowerCAmelCase								=					tokenize_chinese_chars
        __lowerCAmelCase								=					normalizer_class(**SCREAMING_SNAKE_CASE_				)

      __lowerCAmelCase								=					do_lower_case





    def 						A		( self    :		List[Any]      ,    snake_case    :		Dict      ,    snake_case    :		Tuple=None				):

      """simple docstring"""





      __lowerCAmelCase								=					[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 						A		( self    :		Optional[int]      ,    snake_case    :		List[int]      ,    snake_case    :		Optional[List[int]] = None				):

      """simple docstring"""





      __lowerCAmelCase								=					[self.sep_token_id]
      __lowerCAmelCase								=					[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 						A		( self    :		Union[str, Any]      ,    snake_case    :		str      ,    snake_case    :		Optional[str] = None				):

      """simple docstring"""





      __lowerCAmelCase								=					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


