






"""simple docstring"""


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						(				_lowerCAmelCase		):


   '''simple docstring'''

   A_		:      Any							=					VOCAB_FILES_NAMES
   A_		:      Tuple							=					PRETRAINED_VOCAB_FILES_MAP
   A_		:      Optional[int]							=					PRETRAINED_INIT_CONFIGURATION
   A_		:      List[Any]							=					PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   A_		:      Optional[int]							=					LayoutLMTokenizer


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

     '''simple docstring'''
     super().__init__(
         _lowerCamelCase,			tokenizer_file=_lowerCamelCase,			do_lower_case=_lowerCamelCase,			unk_token=_lowerCamelCase,			sep_token=_lowerCamelCase,			pad_token=_lowerCamelCase,			cls_token=_lowerCamelCase,			mask_token=_lowerCamelCase,			tokenize_chinese_chars=_lowerCamelCase,			strip_accents=_lowerCamelCase,			**_lowerCamelCase,			)

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

     __A		     =					do_lower_case


   def 							_SCREAMING_SNAKE_CASE							(      self					:	Tuple,			_lowerCamelCase					:	List[Any],			_lowerCamelCase					:	Dict=None    ):

     '''simple docstring'''
     __A		     =					[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[Any],			_lowerCamelCase					:	List[int],			_lowerCamelCase					:	Optional[List[int]] = None    ):

     '''simple docstring'''
     __A		     =					[self.sep_token_id]
     __A		     =					[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					:	Optional[Any],			_lowerCamelCase					:	str,			_lowerCamelCase					:	Optional[str] = None    ):

     '''simple docstring'''
     __A		     =					self._tokenizer.model.save(_lowerCamelCase,			name=_lowerCamelCase    )
     return tuple(_lowerCamelCase    )











'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


A_				     =							{
    "configuration_sam": [
        "SAM_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "SamConfig",
        "SamMaskDecoderConfig",
        "SamPromptEncoderConfig",
        "SamVisionConfig",
    ],
    "processing_sam": ["SamProcessor"],
}


try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A_				     =							[
        "SAM_PRETRAINED_MODEL_ARCHIVE_LIST",
        "SamModel",
        "SamPreTrainedModel",
    ]
try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A_				     =							[
        "TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST",
        "TFSamModel",
        "TFSamPreTrainedModel",
    ]
try:
    if not is_vision_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A_				     =							["SamImageProcessor"]


if TYPE_CHECKING:
    from .configuration_sam import (
        SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
        SamConfig,
        SamMaskDecoderConfig,
        SamPromptEncoderConfig,
        SamVisionConfig,
    )
    from .processing_sam import SamProcessor

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

    try:
        if not is_vision_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .image_processing_sam import SamImageProcessor

else:
    import sys

    A_				     =							_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





