
"""simple docstring"""





from typing import TYPE_CHECKING

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


_a									=				{
    'configuration_layoutlm': ['LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LayoutLMConfig', 'LayoutLMOnnxConfig'],
    'tokenization_layoutlm': ['LayoutLMTokenizer'],
}

try:
    if not is_tokenizers_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _a									=				['LayoutLMTokenizerFast']

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _a									=				[
        'LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST',
        'LayoutLMForMaskedLM',
        'LayoutLMForSequenceClassification',
        'LayoutLMForTokenClassification',
        'LayoutLMForQuestionAnswering',
        'LayoutLMModel',
        'LayoutLMPreTrainedModel',
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _a									=				[
        'TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST',
        'TFLayoutLMForMaskedLM',
        'TFLayoutLMForSequenceClassification',
        'TFLayoutLMForTokenClassification',
        'TFLayoutLMForQuestionAnswering',
        'TFLayoutLMMainLayer',
        'TFLayoutLMModel',
        'TFLayoutLMPreTrainedModel',
    ]


if TYPE_CHECKING:
    from .configuration_layoutlm import LAYOUTLM_PRETRAINED_CONFIG_ARCHIVE_MAP, LayoutLMConfig, LayoutLMOnnxConfig
    from .tokenization_layoutlm import LayoutLMTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_layoutlm_fast import LayoutLMTokenizerFast

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_layoutlm import (
            LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST,
            LayoutLMForMaskedLM,
            LayoutLMForQuestionAnswering,
            LayoutLMForSequenceClassification,
            LayoutLMForTokenClassification,
            LayoutLMModel,
            LayoutLMPreTrainedModel,
        )
    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_layoutlm import (
            TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFLayoutLMForMaskedLM,
            TFLayoutLMForQuestionAnswering,
            TFLayoutLMForSequenceClassification,
            TFLayoutLMForTokenClassification,
            TFLayoutLMMainLayer,
            TFLayoutLMModel,
            TFLayoutLMPreTrainedModel,
        )

else:
    import sys

    _a									=				_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





"""simple docstring"""



import os
from shutil import copyfile
from typing import Optional, Tuple

from ...file_utils import is_sentencepiece_available
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging


if is_sentencepiece_available():
 from .tokenization_deberta_va import DebertaVaTokenizer
else:
 SCREAMING_SNAKE_CASE_       :						List[str]					=    None

SCREAMING_SNAKE_CASE_       :						int					=    logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_       :						Any					=    {'vocab_file': 'spm.model', 'tokenizer_file': 'tokenizer.json'}

SCREAMING_SNAKE_CASE_       :						Optional[int]					=    {
    'vocab_file': {
        'microsoft/deberta-v2-xlarge': 'https://huggingface.co/microsoft/deberta-v2-xlarge/resolve/main/spm.model',
        'microsoft/deberta-v2-xxlarge': 'https://huggingface.co/microsoft/deberta-v2-xxlarge/resolve/main/spm.model',
        'microsoft/deberta-v2-xlarge-mnli': (
            'https://huggingface.co/microsoft/deberta-v2-xlarge-mnli/resolve/main/spm.model'
        ),
        'microsoft/deberta-v2-xxlarge-mnli': (
            'https://huggingface.co/microsoft/deberta-v2-xxlarge-mnli/resolve/main/spm.model'
        ),
    }
}

SCREAMING_SNAKE_CASE_       :						Optional[Any]					=    {
    'microsoft/deberta-v2-xlarge': 5_1_2,
    'microsoft/deberta-v2-xxlarge': 5_1_2,
    'microsoft/deberta-v2-xlarge-mnli': 5_1_2,
    'microsoft/deberta-v2-xxlarge-mnli': 5_1_2,
}

SCREAMING_SNAKE_CASE_       :						Optional[Any]					=    {
    'microsoft/deberta-v2-xlarge': {'do_lower_case': False},
    'microsoft/deberta-v2-xxlarge': {'do_lower_case': False},
    'microsoft/deberta-v2-xlarge-mnli': {'do_lower_case': False},
    'microsoft/deberta-v2-xxlarge-mnli': {'do_lower_case': False},
}



class        a    (							_lowerCamelCase					):



    """simple docstring"""



    UpperCAmelCase    			=       VOCAB_FILES_NAMES
    UpperCAmelCase    			=       PRETRAINED_VOCAB_FILES_MAP
    UpperCAmelCase    			=       PRETRAINED_INIT_CONFIGURATION
    UpperCAmelCase    			=       PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
    UpperCAmelCase    			=       DebertaVaTokenizer

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






         """simple docstring"""


         super().__init__(
             UpperCamelCase     ,    tokenizer_file=UpperCamelCase     ,    do_lower_case=UpperCamelCase     ,    bos_token=UpperCamelCase     ,    eos_token=UpperCamelCase     ,    unk_token=UpperCamelCase     ,    sep_token=UpperCamelCase     ,    pad_token=UpperCamelCase     ,    cls_token=UpperCamelCase     ,    mask_token=UpperCamelCase     ,    split_by_punct=UpperCamelCase     ,    **UpperCamelCase     ,    )

         A__				      =	do_lower_case
         A__				      =	split_by_punct
         A__				      =	vocab_file
         A__				      =	False if not self.vocab_file else True

    def 					UpperCamelCase						(  self:			Dict     ,    UpperCamelCase:			List[Any]     ,    UpperCamelCase:			Optional[int]=None							):






         """simple docstring"""


         if token_ids_a is None:
              return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
         A__				      =	[self.cls_token_id]
         A__				      =	[self.sep_token_id]
         return cls + token_ids_a + sep + token_ids_a + sep

    def 					UpperCamelCase						(  self:			Tuple     ,    UpperCamelCase:			Any     ,    UpperCamelCase:			Optional[Any]=None     ,    UpperCamelCase:			Tuple=False							):






         """simple docstring"""


         if already_has_special_tokens:
              return super().get_special_tokens_mask(
                  token_ids_a=UpperCamelCase     ,    token_ids_a=UpperCamelCase     ,    already_has_special_tokens=UpperCamelCase							)

         if token_ids_a is not None:
              return [1] + ([0] * len(UpperCamelCase							)) + [1] + ([0] * len(UpperCamelCase							)) + [1]
         return [1] + ([0] * len(UpperCamelCase							)) + [1]

    def 					UpperCamelCase						(  self:			int     ,    UpperCamelCase:			Tuple     ,    UpperCamelCase:			Dict=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 					UpperCamelCase						(  self:			Dict     ,    UpperCamelCase:			str     ,    UpperCamelCase:			Optional[str] = None							):






         """simple docstring"""


         if not self.can_save_slow_tokenizer:
              raise ValueError(
                  """Your fast tokenizer does not have the necessary information to save the vocabulary for a slow """
                  """tokenizer."""							)

         if not os.path.isdir(UpperCamelCase							):
              logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""							)
              return
         A__				      =	os.path.join(
             UpperCamelCase     ,    (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""]							)

         if os.path.abspath(self.vocab_file							) != os.path.abspath(UpperCamelCase							):
              copyfile(self.vocab_file     ,    UpperCamelCase							)

         return (out_vocab_file,)






