


"""simple docstring"""



import json
from typing import List, Optional, Tuple

from tokenizers import pre_tokenizers, processors

from ...tokenization_utils_base import AddedToken, BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_mvp import MvpTokenizer


__snake_case             =   logging.get_logger(__name__)


__snake_case             =   {"""vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", """tokenizer_file""": """tokenizer.json"""}

# See all MVP models at https://huggingface.co/models?filter=mvp
__snake_case             =   {
    """vocab_file""": {
        """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/vocab.json""",
    },
    """added_tokens.json""": {
        """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/added_tokens.json""",
    },
    """merges_file""": {
        """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/merges.txt""",
    },
    """tokenizer_file""": {
        """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/tokenizer.json""",
    },
}

__snake_case             =   {
    """RUCAIBox/mvp""": 1024,
}







class _lowerCAmelCase    (				snake_case_     ):
   __UpperCAmelCase			:	int							  =  VOCAB_FILES_NAMES
   __UpperCAmelCase			:	Tuple							  =  PRETRAINED_VOCAB_FILES_MAP
   __UpperCAmelCase			:	List[str]							  =  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
   __UpperCAmelCase			:	Tuple							  =  ['''input_ids''', '''attention_mask''']
   __UpperCAmelCase			:	Optional[Any]							  =  MvpTokenizer







   def __init__(     self						,     UpperCamelCase__=None						,     UpperCamelCase__=None						,     UpperCamelCase__=None						,     UpperCamelCase__="replace"						,     UpperCamelCase__="<s>"						,     UpperCamelCase__="</s>"						,     UpperCamelCase__="</s>"						,     UpperCamelCase__="<s>"						,     UpperCamelCase__="<unk>"						,     UpperCamelCase__="<pad>"						,     UpperCamelCase__="<mask>"						,     UpperCamelCase__=False						,     UpperCamelCase__=True						,     **UpperCamelCase__						,     )     ->		List[str]:

       '''simple docstring'''




       super().__init__(
           UpperCamelCase__						,     UpperCamelCase__						,     tokenizer_file=UpperCamelCase__						,     errors=UpperCamelCase__						,     bos_token=UpperCamelCase__						,     eos_token=UpperCamelCase__						,     sep_token=UpperCamelCase__						,     cls_token=UpperCamelCase__						,     unk_token=UpperCamelCase__						,     pad_token=UpperCamelCase__						,     mask_token=UpperCamelCase__						,     add_prefix_space=UpperCamelCase__						,     trim_offsets=UpperCamelCase__						,     **UpperCamelCase__						,     )

       snake_case   :				Tuple				 =   json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()						)
       if pre_tok_state.get("add_prefix_space"						,     UpperCamelCase__						) != add_prefix_space:
           snake_case   :				Any				 =   getattr(UpperCamelCase__						,     pre_tok_state.pop("type"						)						)
           snake_case   :				str				 =   add_prefix_space
           snake_case   :				Optional[Any]				 =   pre_tok_class(**UpperCamelCase__						)

       snake_case   :				Optional[Any]				 =   add_prefix_space

       # the pre_tokenizer is already updated in the GPT2TokenizerFast `__init__`
       snake_case   :				Any				 =   "post_processor"
       snake_case   :				str				 =   getattr(self.backend_tokenizer						,     UpperCamelCase__						,     UpperCamelCase__						)
       if tokenizer_component_instance:
           snake_case   :				Dict				 =   json.loads(tokenizer_component_instance.__getstate__()						)

           # The lists 'sep' and 'cls' must be cased in tuples for the object `post_processor_class`
           if "sep" in state:
               snake_case   :				Tuple				 =   tuple(state["sep"]						)
           if "cls" in state:
               snake_case   :				List[Any]				 =   tuple(state["cls"]						)

           snake_case   :				Tuple				 =   False

           if state.get("add_prefix_space"						,     UpperCamelCase__						) != add_prefix_space:
               snake_case   :				List[Any]				 =   add_prefix_space
               snake_case   :				Tuple				 =   True

           if state.get("trim_offsets"						,     UpperCamelCase__						) != trim_offsets:
               snake_case   :				List[Any]				 =   trim_offsets
               snake_case   :				Dict				 =   True

           if changes_to_apply:
               snake_case   :				List[str]				 =   getattr(UpperCamelCase__						,     state.pop("type"						)						)
               snake_case   :				Optional[int]				 =   component_class(**UpperCamelCase__						)
               setattr(self.backend_tokenizer						,     UpperCamelCase__						,     UpperCamelCase__						)







   @property
   def 			lowerCamelCase		(     self						)     ->		str:

       '''simple docstring'''




       if self._mask_token is None:
           if self.verbose:
               logger.error("Using mask_token, but it is not set yet."						)
           return None
       return str(self._mask_token						)







   @mask_token.setter
   def 			lowerCamelCase		(     self						,     UpperCamelCase__						)     ->		int:

       '''simple docstring'''




       snake_case   :				int				 =   AddedToken(UpperCamelCase__						,     lstrip=UpperCamelCase__						,     rstrip=UpperCamelCase__						) if isinstance(UpperCamelCase__						,     UpperCamelCase__						) else value
       snake_case   :				int				 =   value







   def 			lowerCamelCase		(     self						,     *UpperCamelCase__						,     **UpperCamelCase__						)     ->		BatchEncoding:

       '''simple docstring'''




       snake_case   :				Dict				 =   kwargs.get("is_split_into_words"						,     UpperCamelCase__						)

       if is_split_into_words and not self.add_prefix_space:
           raise ValueError(
               F'You need to instantiate {self.__class__.__name__} with add_prefix_space=True '
               "to use it with pretokenized inputs."						)

       return super()._batch_encode_plus(*UpperCamelCase__						,     **UpperCamelCase__						)







   def 			lowerCamelCase		(     self						,     *UpperCamelCase__						,     **UpperCamelCase__						)     ->		BatchEncoding:

       '''simple docstring'''




       snake_case   :				List[str]				 =   kwargs.get("is_split_into_words"						,     UpperCamelCase__						)

       if is_split_into_words and not self.add_prefix_space:
           raise ValueError(
               F'You need to instantiate {self.__class__.__name__} with add_prefix_space=True '
               "to use it with pretokenized inputs."						)

       return super()._encode_plus(*UpperCamelCase__						,     **UpperCamelCase__						)







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__ = None						)     ->		Tuple[str]:

       '''simple docstring'''




       snake_case   :				List[str]				 =   self._tokenizer.model.save(UpperCamelCase__						,     name=UpperCamelCase__						)
       return tuple(UpperCamelCase__						)







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__=None						)     ->		List[str]:

       '''simple docstring'''




       snake_case   :				Dict				 =   [self.bos_token_id] + token_ids_a + [self.eos_token_id]
       if token_ids_a is None:
           return output

       return output + [self.eos_token_id] + token_ids_a + [self.eos_token_id]







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__ = None						)     ->		List[int]:

       '''simple docstring'''




       snake_case   :				Optional[int]				 =   [self.sep_token_id]
       snake_case   :				List[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 + sep + token_ids_a + sep						) * [0]









"""simple docstring"""



from . import __version__

# Backward compatibility imports, to make sure all those objects can be found in file_utils
from .utils import (
    CLOUDFRONT_DISTRIB_PREFIX,
    CONFIG_NAME,
    DISABLE_TELEMETRY,
    DUMMY_INPUTS,
    DUMMY_MASK,
    ENV_VARS_TRUE_AND_AUTO_VALUES,
    ENV_VARS_TRUE_VALUES,
    FEATURE_EXTRACTOR_NAME,
    FLAX_WEIGHTS_NAME,
    HF_MODULES_CACHE,
    HUGGINGFACE_CO_PREFIX,
    HUGGINGFACE_CO_RESOLVE_ENDPOINT,
    MODEL_CARD_NAME,
    MULTIPLE_CHOICE_DUMMY_INPUTS,
    PYTORCH_PRETRAINED_BERT_CACHE,
    PYTORCH_TRANSFORMERS_CACHE,
    S3_BUCKET_PREFIX,
    SENTENCEPIECE_UNDERLINE,
    SPIECE_UNDERLINE,
    TF2_WEIGHTS_NAME,
    TF_WEIGHTS_NAME,
    TORCH_FX_REQUIRED_VERSION,
    TRANSFORMERS_CACHE,
    TRANSFORMERS_DYNAMIC_MODULE_NAME,
    USE_JAX,
    USE_TF,
    USE_TORCH,
    WEIGHTS_INDEX_NAME,
    WEIGHTS_NAME,
    ContextManagers,
    DummyObject,
    EntryNotFoundError,
    ExplicitEnum,
    ModelOutput,
    PaddingStrategy,
    PushToHubMixin,
    RepositoryNotFoundError,
    RevisionNotFoundError,
    TensorType,
    _LazyModule,
    add_code_sample_docstrings,
    add_end_docstrings,
    add_start_docstrings,
    add_start_docstrings_to_model_forward,
    cached_property,
    copy_func,
    default_cache_path,
    define_sagemaker_information,
    get_cached_models,
    get_file_from_repo,
    get_full_repo_name,
    get_torch_version,
    has_file,
    http_user_agent,
    is_apex_available,
    is_bsa_available,
    is_coloredlogs_available,
    is_datasets_available,
    is_detectrona_available,
    is_faiss_available,
    is_flax_available,
    is_ftfy_available,
    is_in_notebook,
    is_ipex_available,
    is_librosa_available,
    is_offline_mode,
    is_onnx_available,
    is_pandas_available,
    is_phonemizer_available,
    is_protobuf_available,
    is_psutil_available,
    is_pyanvml_available,
    is_pyctcdecode_available,
    is_pytesseract_available,
    is_pytorch_quantization_available,
    is_rjieba_available,
    is_sagemaker_dp_enabled,
    is_sagemaker_mp_enabled,
    is_scipy_available,
    is_sentencepiece_available,
    is_seqio_available,
    is_sklearn_available,
    is_soundfile_availble,
    is_spacy_available,
    is_speech_available,
    is_tensor,
    is_tensorflow_probability_available,
    is_tfaonnx_available,
    is_tf_available,
    is_timm_available,
    is_tokenizers_available,
    is_torch_available,
    is_torch_bfaa_available,
    is_torch_cuda_available,
    is_torch_fx_available,
    is_torch_fx_proxy,
    is_torch_mps_available,
    is_torch_tfaa_available,
    is_torch_tpu_available,
    is_torchaudio_available,
    is_training_run_on_sagemaker,
    is_vision_available,
    replace_return_docstrings,
    requires_backends,
    to_numpy,
    to_py_obj,
    torch_only_method,
)





