class_docstr: Adapted from [`RobertaTokenizer`] and [`XLNetTokenizer`]. Construct a CamemBERT tokenizer. Based on
  [SentencePiece](https://github.com/google/sentencepiece).
  
  This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
  this superclass for more information regarding those methods.
  
  Args:
      vocab_file (`str`):
          [SentencePiece](https://github.com/google/sentencepiece) file (generally has a *.spm* extension) that
          contains the vocabulary necessary to instantiate a tokenizer.
      bos_token (`str`, *optional*, defaults to `"<s>"`):
          The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.
  
          <Tip>
  
          When building a sequence using special tokens, this is not the token that is used for the beginning of
          sequence. The token used is the `cls_token`.
  
          </Tip>
  
      eos_token (`str`, *optional*, defaults to `"</s>"`):
          The end of sequence token.
  
          <Tip>
  
          When building a sequence using special tokens, this is not the token that is used for the end of sequence.
          The token used is the `sep_token`.
  
          </Tip>
  
      sep_token (`str`, *optional*, defaults to `"</s>"`):
          The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
          sequence classification or for a text and a question for question answering. It is also used as the last
          token of a sequence built with special tokens.
      cls_token (`str`, *optional*, defaults to `"<s>"`):
          The classifier token which is used when doing sequence classification (classification of the whole sequence
          instead of per-token classification). It is the first token of the sequence when built with special tokens.
      unk_token (`str`, *optional*, defaults to `"<unk>"`):
          The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
          token instead.
      pad_token (`str`, *optional*, defaults to `"<pad>"`):
          The token used for padding, for example when batching sequences of different lengths.
      mask_token (`str`, *optional*, defaults to `"<mask>"`):
          The token used for masking values. This is the token used when training this model with masked language
          modeling. This is the token which the model will try to predict.
      additional_special_tokens (`List[str]`, *optional*, defaults to `['<s>NOTUSED', '</s>NOTUSED', '<unk>NOTUSED']`):
          Additional special tokens used by the tokenizer.
      sp_model_kwargs (`dict`, *optional*):
          Will be passed to the `SentencePieceProcessor.__init__()` method. The [Python wrapper for
          SentencePiece](https://github.com/google/sentencepiece/tree/master/python) can be used, among other things,
          to set:
  
          - `enable_sampling`: Enable subword regularization.
          - `nbest_size`: Sampling parameters for unigram. Invalid for BPE-Dropout.
  
            - `nbest_size = {0,1}`: No sampling is performed.
            - `nbest_size > 1`: samples from the nbest_size results.
            - `nbest_size < 0`: assuming that nbest_size is infinite and samples from the all hypothesis (lattice)
              using forward-filtering-and-backward-sampling algorithm.
  
          - `alpha`: Smoothing parameter for unigram sampling, and dropout probability of merge operations for
            BPE-dropout.
  
  Attributes:
      sp_model (`SentencePieceProcessor`):
          The *SentencePiece* processor that is used for every conversion (string, tokens and IDs).
class_docstr_tok: ["Adapted","from","[","`","RobertaTokenizer","`","]","and","[","`","XLNetTokenizer","`","]",".","Construct","a","CamemBERT","tokenizer",".","Based","on","[","SentencePiece","]","(","https",":","\/\/github.com\/google\/sentencepiece",")",".","This","tokenizer","inherits","from","[","`","PreTrainedTokenizer","`","]","which","contains","most","of","the","main","methods",".","Users","should","refer","to","this","superclass","for","more","information","regarding","those","methods",".","Args",":","vocab_file","(","`","str","`",")",":","[","SentencePiece","]","(","https",":","\/\/github.com\/google\/sentencepiece",")","file","(","generally","has","a","*",".spm","*","extension",")","that","contains","the","vocabulary","necessary","to","instantiate","a","tokenizer",".","bos_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","s",">","''","`",")",":","The","beginning","of","sequence","token","that","was","used","during","pretraining",".","Can","be","used","a","sequence","classifier","token",".","<","Tip",">","When","building","a","sequence","using","special","tokens",",","this","is","not","the","token","that","is","used","for","the","beginning","of","sequence",".","The","token","used","is","the","`","cls_token","`",".","<","\/Tip",">","eos_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","\/s",">","''","`",")",":","The","end","of","sequence","token",".","<","Tip",">","When","building","a","sequence","using","special","tokens",",","this","is","not","the","token","that","is","used","for","the","end","of","sequence",".","The","token","used","is","the","`","sep_token","`",".","<","\/Tip",">","sep_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","\/s",">","''","`",")",":","The","separator","token",",","which","is","used","when","building","a","sequence","from","multiple","sequences",",","e.g",".","two","sequences","for","sequence","classification","or","for","a","text","and","a","question","for","question","answering",".","It","is","also","used","as","the","last","token","of","a","sequence","built","with","special","tokens",".","cls_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","s",">","''","`",")",":","The","classifier","token","which","is","used","when","doing","sequence","classification","(","classification","of","the","whole","sequence","instead","of","per-token","classification",")",".","It","is","the","first","token","of","the","sequence","when","built","with","special","tokens",".","unk_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","unk",">","''","`",")",":","The","unknown","token",".","A","token","that","is","not","in","the","vocabulary","can","not","be","converted","to","an","ID","and","is","set","to","be","this","token","instead",".","pad_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","pad",">","''","`",")",":","The","token","used","for","padding",",","for","example","when","batching","sequences","of","different","lengths",".","mask_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","mask",">","''","`",")",":","The","token","used","for","masking","values",".","This","is","the","token","used","when","training","this","model","with","masked","language","modeling",".","This","is","the","token","which","the","model","will","try","to","predict",".","additional_special_tokens","(","`","List","[","str","]","`",",","*","optional","*",",","defaults","to","`","[","'","<","s",">","NOTUSED","'",",","'","<","\/s",">","NOTUSED","'",",","'","<","unk",">","NOTUSED","'","]","`",")",":","Additional","special","tokens","used","by","the","tokenizer",".","sp_model_kwargs","(","`","dict","`",",","*","optional","*",")",":","Will","be","passed","to","the","`","SentencePieceProcessor.__init__","(",")","`","method",".","The","[","Python","wrapper","for","SentencePiece","]","(","https",":","\/\/github.com\/google\/sentencepiece\/tree\/master\/python",")","can","be","used",",","among","other","things",",","to","set",":","-","`","enable_sampling","`",":","Enable","subword","regularization",".","-","`","nbest_size","`",":","Sampling","parameters","for","unigram",".","Invalid","for","BPE-Dropout",".","-","`","nbest_size","=","{","0,1","}","`",":","No","sampling","is","performed",".","-","`","nbest_size",">","1","`",":","samples","from","the","nbest_size","results",".","-","`","nbest_size","<","0","`",":","assuming","that","nbest_size","is","infinite","and","samples","from","the","all","hypothesis","(","lattice",")","using","forward-filtering-and-backward-sampling","algorithm",".","-","`","alpha","`",":","Smoothing","parameter","for","unigram","sampling",",","and","dropout","probability","of","merge","operations","for","BPE-dropout",".","Attributes",":","sp_model","(","`","SentencePieceProcessor","`",")",":","The","*","SentencePiece","*","processor","that","is","used","for","every","conversion","(","string",",","tokens","and","IDs",")","."]
code: def __init__(
      self,
      vocab_file,
      bos_token="<s>",
      eos_token="</s>",
      sep_token="</s>",
      cls_token="<s>",
      unk_token="<unk>",
      pad_token="<pad>",
      mask_token="<mask>",
      additional_special_tokens=[
          "<s>NOTUSED",
          "</s>NOTUSED",
          "<unk>NOTUSED",
      ],
      sp_model_kwargs: Optional[Dict[str, Any]] = None,
      **kwargs,
  ) -> None:
      # Mask token behave like a normal word, i.e. include the space before it
      mask_token = (
          AddedToken(
              mask_token,
              lstrip=True,
              rstrip=False,
              normalized=False,
              special=True,
          )
          if isinstance(mask_token, str)
          else mask_token
      )
  
      self.sp_model_kwargs = (
          {} if sp_model_kwargs is None else sp_model_kwargs
      )
  
      self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
      self.sp_model.Load(str(vocab_file))
      self.vocab_file = vocab_file
  
      # HACK: These tokens were added by the author for an obscure reason as they were already part of the
      # sentencepiece vocabulary (this is the case for <s> and </s> and <unk>).
      # In this case it is recommended to properly set the tokens by hand.
      self._added_tokens_decoder = {
          0: AddedToken("<s>NOTUSED", special=True),
          1: AddedToken(pad_token, special=True)
          if isinstance(pad_token, str)
          else pad_token,
          2: AddedToken("</s>NOTUSED", special=True),
          3: AddedToken(unk_token, special=True)
          if isinstance(unk_token, str)
          else unk_token,
          4: AddedToken("<unk>NOTUSED", special=True),
      }
  
      self.fairseq_offset = (
          4  # 3 tokens are newly added, but the offset starts from 4
      )
  
      # legacy: camemebert is a particular case were we have to make sure `"<unk>NOTUSED"` is here
      if "added_tokens_decoder" in kwargs:
          # this is the only class that requires this unfortunately.....
          # the reason is that the fast version has a whole.
          kwargs["added_tokens_decoder"].update(
              self._added_tokens_decoder
          )
  
      super().__init__(
          bos_token=bos_token,
          eos_token=eos_token,
          unk_token=unk_token,
          sep_token=sep_token,
          cls_token=cls_token,
          pad_token=pad_token,
          mask_token=mask_token,
          additional_special_tokens=additional_special_tokens,
          sp_model_kwargs=self.sp_model_kwargs,
          **kwargs,
      )
  
imports: import os
  from shutil import copyfile
  from typing import Any, Dict, List, Optional, Tuple
  import sentencepiece
  from ...tokenization_utils import AddedToken, PreTrainedTokenizer
  from ...utils import logging
label_desc: Use image node_id 1 to create a new CamembertTokenizer object from inherited base classes: PreTrainedTokenizer with example: obj = CamembertTokenizer(vocab_file, bos_token, eos_token, sep_token, cls_token, unk_token, pad_token, mask_token, additional_special_tokens, sp_model_kwargs)