





from typing import Dict, List, Optional

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


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


_snake_case  :    List[str]						    =  {
    'nielsr/canine-s': 2048,
}

# Unicode defines 1,114,112 total “codepoints”
_snake_case  :    List[str]						    =  1114112

# Below: Constants defining canonical codepoints for special, pseudo-characters.
# Copied from https://github.com/google-research/language/blob/master/language/canine/special_codepoints.py
_snake_case  :    Dict						    =  0

_snake_case  :    Optional[int]						    =  0XE000
_snake_case  :    Optional[int]						    =  0XE001
_snake_case  :    List[str]						    =  0XE002
_snake_case  :    Dict						    =  0XE003
_snake_case  :    Any						    =  0XE004

# Maps special codepoints to human-readable names.
_snake_case  :    Dict[int, str]						    =  {
    # Special symbols are represented using codepoints values that are valid,
    # but designated as "Private Use", meaning that they will never be assigned
    # characters by the Unicode Consortium, and are thus safe for use here.
    #
    # NOTE: Do *NOT* add any sort of [UNK_CHAR] here. They are explicitly
    # excluded and should fail with a hard error.
    CLS: "[CLS]",
    SEP: "[SEP]",
    BOS: "[BOS]",
    MASK: "[MASK]",
    PAD: "[PAD]",
    RESERVED: "[RESERVED]",
}

# Maps special codepoint human-readable names to their codepoint values.
_snake_case  :    Dict[str, int]						    =  {name: codepoint for codepoint, name in SPECIAL_CODEPOINTS.items()}



class 				_UpperCAmelCase    (    _UpperCamelCase    ):

  """simple docstring"""


  a_        = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES






  def __init__(				self :		Optional[Any]					,  lowerCAmelCase_ :		int=chr(lowerCAmelCase_     )					,  lowerCAmelCase_ :		List[Any]=chr(lowerCAmelCase_     )					,  lowerCAmelCase_ :		int=chr(lowerCAmelCase_     )					,  lowerCAmelCase_ :		Tuple=chr(lowerCAmelCase_     )					,  lowerCAmelCase_ :		List[str]=chr(lowerCAmelCase_     )					,  lowerCAmelCase_ :		int=chr(lowerCAmelCase_     )					,  lowerCAmelCase_ :		Tuple=False					,  lowerCAmelCase_ :		Union[str, Any]=2_0_4_8					,  **lowerCAmelCase_ :		str					,  )							->						List[Any]:
     __lowerCAmelCase								=	AddedToken(lowerCAmelCase_					,  lstrip=lowerCAmelCase_					,  rstrip=lowerCAmelCase_     ) if isinstance(lowerCAmelCase_					,  lowerCAmelCase_     ) else bos_token
     __lowerCAmelCase								=	AddedToken(lowerCAmelCase_					,  lstrip=lowerCAmelCase_					,  rstrip=lowerCAmelCase_     ) if isinstance(lowerCAmelCase_					,  lowerCAmelCase_     ) else eos_token
     __lowerCAmelCase								=	AddedToken(lowerCAmelCase_					,  lstrip=lowerCAmelCase_					,  rstrip=lowerCAmelCase_     ) if isinstance(lowerCAmelCase_					,  lowerCAmelCase_     ) else sep_token
     __lowerCAmelCase								=	AddedToken(lowerCAmelCase_					,  lstrip=lowerCAmelCase_					,  rstrip=lowerCAmelCase_     ) if isinstance(lowerCAmelCase_					,  lowerCAmelCase_     ) else cls_token
     __lowerCAmelCase								=	AddedToken(lowerCAmelCase_					,  lstrip=lowerCAmelCase_					,  rstrip=lowerCAmelCase_     ) if isinstance(lowerCAmelCase_					,  lowerCAmelCase_     ) else pad_token

     # Mask token behave like a normal word, i.e. include the space before it
     __lowerCAmelCase								=	AddedToken(lowerCAmelCase_					,  lstrip=lowerCAmelCase_					,  rstrip=lowerCAmelCase_     ) if isinstance(lowerCAmelCase_					,  lowerCAmelCase_     ) else mask_token

     super().__init__(
         bos_token=lowerCAmelCase_					,  eos_token=lowerCAmelCase_					,  sep_token=lowerCAmelCase_					,  cls_token=lowerCAmelCase_					,  pad_token=lowerCAmelCase_					,  mask_token=lowerCAmelCase_					,  add_prefix_space=lowerCAmelCase_					,  model_max_length=lowerCAmelCase_					,  **lowerCAmelCase_					,  )

     # Creates a mapping for looking up the IDs of special symbols.
     __lowerCAmelCase								=	{}
     for codepoint, name in SPECIAL_CODEPOINTS.items():
        __lowerCAmelCase								=	codepoint

     # Creates a mapping for looking up the string forms of special symbol IDs.
     __lowerCAmelCase								=	{
         codepoint: name for name, codepoint in self._special_codepoints.items()
     }

     __lowerCAmelCase								=	UNICODE_VOCAB_SIZE
     __lowerCAmelCase								=	len(self._special_codepoints     )






  @property
  def 				lowercase		(				self :		Dict     )							->						int:
     return self._unicode_vocab_size






  def 				lowercase		(				self :		Any					,  lowerCAmelCase_ :		str     )							->						List[str]:
     return list(lowerCAmelCase_     )






  def 				lowercase		(				self :		Optional[int]					,  lowerCAmelCase_ :		str     )							->						int:
     try:
        return ord(lowerCAmelCase_     )
     except TypeError:
        raise ValueError(f"""invalid token: '{token}'"""     )






  def 				lowercase		(				self :		List[Any]					,  lowerCAmelCase_ :		int     )							->						str:
     try:
        if index in SPECIAL_CODEPOINTS:
           return SPECIAL_CODEPOINTS[index]
        return chr(lowerCAmelCase_     )
     except TypeError:
        raise ValueError(f"""invalid id: {index}"""     )






  def 				lowercase		(				self :		Union[str, Any]					,  lowerCAmelCase_ :		Optional[int]     )							->						Union[str, Any]:
     return "".join(lowerCAmelCase_     )






  def 				lowercase		(				self :		Optional[Any]					,  lowerCAmelCase_ :		List[int]					,  lowerCAmelCase_ :		Optional[List[int]] = None     )							->						List[int]:
     __lowerCAmelCase								=	[self.sep_token_id]
     __lowerCAmelCase								=	[self.cls_token_id]

     __lowerCAmelCase								=	cls + token_ids_a + sep
     if token_ids_a is not None:
        result += token_ids_a + sep
     return result






  def 				lowercase		(				self :		Dict					,  lowerCAmelCase_ :		List[int]					,  lowerCAmelCase_ :		Optional[List[int]] = None					,  lowerCAmelCase_ :		bool = False     )							->						List[int]:
     if already_has_special_tokens:
        return super().get_special_tokens_mask(
            token_ids_a=lowerCAmelCase_					,  token_ids_a=lowerCAmelCase_					,  already_has_special_tokens=lowerCAmelCase_     )

     __lowerCAmelCase								=	[1] + ([0] * len(lowerCAmelCase_     )) + [1]
     if token_ids_a is not None:
        result += ([0] * len(lowerCAmelCase_     )) + [1]
     return result






  def 				lowercase		(				self :		List[str]					,  lowerCAmelCase_ :		List[int]					,  lowerCAmelCase_ :		Optional[List[int]] = None     )							->						List[int]:
     __lowerCAmelCase								=	[self.sep_token_id]
     __lowerCAmelCase								=	[self.cls_token_id]

     __lowerCAmelCase								=	len(cls + token_ids_a + sep     ) * [0]
     if token_ids_a is not None:
        result += len(token_ids_a + sep     ) * [1]
     return result






  def 				lowercase		(				self :		int					,  lowerCAmelCase_ :		str					,  lowerCAmelCase_ :		Optional[str] = None     )							->						Union[str, Any]:
     return ()








from typing import TYPE_CHECKING

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


_snake_case  :    Union[str, Any]						    =  {
    'configuration_layoutlmv3': [
        'LAYOUTLMV3_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'LayoutLMv3Config',
        'LayoutLMv3OnnxConfig',
    ],
    'processing_layoutlmv3': ['LayoutLMv3Processor'],
    'tokenization_layoutlmv3': ['LayoutLMv3Tokenizer'],
}

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _snake_case  :    Union[str, Any]						    =  ['LayoutLMv3TokenizerFast']

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _snake_case  :    List[str]						    =  [
         'LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST',
         'LayoutLMv3ForQuestionAnswering',
         'LayoutLMv3ForSequenceClassification',
         'LayoutLMv3ForTokenClassification',
         'LayoutLMv3Model',
         'LayoutLMv3PreTrainedModel',
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _snake_case  :    Optional[Any]						    =  [
         'TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST',
         'TFLayoutLMv3ForQuestionAnswering',
         'TFLayoutLMv3ForSequenceClassification',
         'TFLayoutLMv3ForTokenClassification',
         'TFLayoutLMv3Model',
         'TFLayoutLMv3PreTrainedModel',
     ]

try:
     if not is_vision_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     _snake_case  :    Tuple						    =  ['LayoutLMv3FeatureExtractor']
     _snake_case  :    str						    =  ['LayoutLMv3ImageProcessor']


if TYPE_CHECKING:
     from .configuration_layoutlmva import (
         LAYOUTLMV3_PRETRAINED_CONFIG_ARCHIVE_MAP,
         LayoutLMvaConfig,
         LayoutLMvaOnnxConfig,
     )
     from .processing_layoutlmva import LayoutLMvaProcessor
     from .tokenization_layoutlmva import LayoutLMvaTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_layoutlmva_fast import LayoutLMvaTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_layoutlmva import (
              LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
              LayoutLMvaForQuestionAnswering,
              LayoutLMvaForSequenceClassification,
              LayoutLMvaForTokenClassification,
              LayoutLMvaModel,
              LayoutLMvaPreTrainedModel,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_layoutlmva import (
              TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFLayoutLMvaForQuestionAnswering,
              TFLayoutLMvaForSequenceClassification,
              TFLayoutLMvaForTokenClassification,
              TFLayoutLMvaModel,
              TFLayoutLMvaPreTrainedModel,
          )

     try:
          if not is_vision_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .feature_extraction_layoutlmva import LayoutLMvaFeatureExtractor
          from .image_processing_layoutlmva import LayoutLMvaImageProcessor

else:
     import sys

     _snake_case  :    Any						    =  _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

