





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

from ...tokenization_utils import AddedToken
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import is_sentencepiece_available, logging


if is_sentencepiece_available():
     from .tokenization_xlnet import XLNetTokenizer
else:
     _snake_case  :    Dict						    =  None


_snake_case  :    List[Any]						    =  logging.get_logger(__name__)

_snake_case  :    str						    =  {"""vocab_file""": """spiece.model""", """tokenizer_file""": """tokenizer.json"""}

_snake_case  :    Union[str, Any]						    =  {
    """vocab_file""": {
        """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/spiece.model""",
        """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/spiece.model""",
    },
    """tokenizer_file""": {
        """xlnet-base-cased""": """https://huggingface.co/xlnet-base-cased/resolve/main/tokenizer.json""",
        """xlnet-large-cased""": """https://huggingface.co/xlnet-large-cased/resolve/main/tokenizer.json""",
    },
}

_snake_case  :    Any						    =  {
    """xlnet-base-cased""": None,
    """xlnet-large-cased""": None,
}

_snake_case  :    Dict						    =  """▁"""

# Segments (not really needed)
_snake_case  :    List[str]						    =  0
_snake_case  :    List[Any]						    =  1
_snake_case  :    Union[str, Any]						    =  2
_snake_case  :    List[Any]						    =  3
_snake_case  :    str						    =  4



class 				_UpperCAmelCase    (    _UpperCAmelCase    ):

  """simple docstring"""


  a_        = VOCAB_FILES_NAMES
  a_        = PRETRAINED_VOCAB_FILES_MAP
  a_        = PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
  a_        = 'left'
  a_        = XLNetTokenizer






  def __init__(				self :		str					,  lowerCAmelCase_ :		Dict=None					,  lowerCAmelCase_ :		Any=None					,  lowerCAmelCase_ :		Any=False					,  lowerCAmelCase_ :		List[Any]=True					,  lowerCAmelCase_ :		Any=False					,  lowerCAmelCase_ :		str="<s>"					,  lowerCAmelCase_ :		Dict="</s>"					,  lowerCAmelCase_ :		List[Any]="<unk>"					,  lowerCAmelCase_ :		Dict="<sep>"					,  lowerCAmelCase_ :		List[Any]="<pad>"					,  lowerCAmelCase_ :		int="<cls>"					,  lowerCAmelCase_ :		Optional[int]="<mask>"					,  lowerCAmelCase_ :		str=["<eop>", "<eod>"]					,  **lowerCAmelCase_ :		Any					,  )							->						Union[str, Any]:
     # Mask token behave like a normal word, i.e. include the space before it
     __lowerCAmelCase								=	AddedToken(SCREAMING_SNAKE_CASE_					,  lstrip=SCREAMING_SNAKE_CASE_					,  rstrip=SCREAMING_SNAKE_CASE_     ) if isinstance(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_     ) else mask_token

     super().__init__(
         vocab_file=SCREAMING_SNAKE_CASE_					,  tokenizer_file=SCREAMING_SNAKE_CASE_					,  do_lower_case=SCREAMING_SNAKE_CASE_					,  remove_space=SCREAMING_SNAKE_CASE_					,  keep_accents=SCREAMING_SNAKE_CASE_					,  bos_token=SCREAMING_SNAKE_CASE_					,  eos_token=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_					,  additional_special_tokens=SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_					,  )

     __lowerCAmelCase								=	3
     __lowerCAmelCase								=	do_lower_case
     __lowerCAmelCase								=	remove_space
     __lowerCAmelCase								=	keep_accents
     __lowerCAmelCase								=	vocab_file
     __lowerCAmelCase								=	False if not self.vocab_file else True






  def 				lowercase		(				self :		str					,  lowerCAmelCase_ :		Tuple					,  lowerCAmelCase_ :		Any = None     )							->						List[int]:
     __lowerCAmelCase								=	[self.sep_token_id]
     __lowerCAmelCase								=	[self.cls_token_id]
     if token_ids_a is None:
        return token_ids_a + sep + cls
     return token_ids_a + sep + token_ids_a + sep + cls






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

     if token_ids_a is None:
        return len(token_ids_a + sep     ) * [0] + cls_segment_id
     return len(token_ids_a + sep     ) * [0] + len(token_ids_a + sep     ) * [1] + cls_segment_id






  def 				lowercase		(				self :		Union[str, Any]					,  lowerCAmelCase_ :		Tuple					,  lowerCAmelCase_ :		Any = None     )							->						Tuple[str]:
     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(SCREAMING_SNAKE_CASE_     ):
        logger.error(f"""Vocabulary path ({save_directory}) should be a directory"""     )
        return
     __lowerCAmelCase								=	os.path.join(
         SCREAMING_SNAKE_CASE_					,  (filename_prefix + '-' if filename_prefix else '') + VOCAB_FILES_NAMES['vocab_file']     )

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

     return (out_vocab_file,)





'''simple docstring'''



from . import (
    albert,
    align,
    altclip,
    audio_spectrogram_transformer,
    auto,
    autoformer,
    bark,
    bart,
    barthez,
    bartpho,
    beit,
    bert,
    bert_generation,
    bert_japanese,
    bertweet,
    big_bird,
    bigbird_pegasus,
    biogpt,
    bit,
    blenderbot,
    blenderbot_small,
    blip,
    blip_a,
    bloom,
    bridgetower,
    byta,
    camembert,
    canine,
    chinese_clip,
    clap,
    clip,
    clipseg,
    codegen,
    conditional_detr,
    convbert,
    convnext,
    convnextva,
    cpm,
    cpmant,
    ctrl,
    cvt,
    dataavec,
    deberta,
    deberta_va,
    decision_transformer,
    deformable_detr,
    deit,
    deprecated,
    deta,
    detr,
    dialogpt,
    dinat,
    distilbert,
    dit,
    donut,
    dpr,
    dpt,
    efficientformer,
    efficientnet,
    electra,
    encodec,
    encoder_decoder,
    ernie,
    ernie_m,
    esm,
    falcon,
    flaubert,
    flava,
    fnet,
    focalnet,
    fsmt,
    funnel,
    git,
    glpn,
    gpta,
    gpt_bigcode,
    gpt_neo,
    gpt_neox,
    gpt_neox_japanese,
    gpt_swa,
    gptj,
    gptsan_japanese,
    graphormer,
    groupvit,
    herbert,
    hubert,
    ibert,
    imagegpt,
    informer,
    instructblip,
    jukebox,
    layoutlm,
    layoutlmva,
    layoutlmva,
    layoutxlm,
    led,
    levit,
    lilt,
    llama,
    longformer,
    longta,
    luke,
    lxmert,
    mam_aaa,
    marian,
    markuplm,
    maskaformer,
    maskformer,
    mbart,
    mbartaa,
    mega,
    megatron_bert,
    megatron_gpta,
    mgp_str,
    mluke,
    mobilebert,
    mobilenet_va,
    mobilenet_va,
    mobilevit,
    mobilevitva,
    mpnet,
    mra,
    mta,
    musicgen,
    mvp,
    nat,
    nezha,
    nllb,
    nllb_moe,
    nystromformer,
    oneformer,
    open_llama,
    openai,
    opt,
    owlvit,
    pegasus,
    pegasus_x,
    perceiver,
    phobert,
    pixastruct,
    plbart,
    poolformer,
    prophetnet,
    qdqbert,
    rag,
    realm,
    reformer,
    regnet,
    rembert,
    resnet,
    roberta,
    roberta_prelayernorm,
    roc_bert,
    roformer,
    rwkv,
    sam,
    segformer,
    sew,
    sew_d,
    speech_encoder_decoder,
    speech_to_text,
    speech_to_text_a,
    speechta,
    splinter,
    squeezebert,
    swiftformer,
    swin,
    swinasr,
    swinva,
    switch_transformers,
    ta,
    table_transformer,
    tapas,
    time_series_transformer,
    timesformer,
    timm_backbone,
    transfo_xl,
    trocr,
    tvlt,
    umta,
    unispeech,
    unispeech_sat,
    upernet,
    videomae,
    vilt,
    vision_encoder_decoder,
    vision_text_dual_encoder,
    visual_bert,
    vit,
    vit_hybrid,
    vit_mae,
    vit_msn,
    vivit,
    wavaveca,
    wavaveca_conformer,
    wavaveca_phoneme,
    wavaveca_with_lm,
    wavlm,
    whisper,
    x_clip,
    xglm,
    xlm,
    xlm_prophetnet,
    xlm_roberta,
    xlm_roberta_xl,
    xlnet,
    xmod,
    yolos,
    yoso,
)






