class_docstr: Construct a Flaubert tokenizer. Based on Byte-Pair Encoding. The tokenization process is the following:
  
  - Moses preprocessing and tokenization.
  - Normalizing all inputs text.
  - The arguments `special_tokens` and the function `set_special_tokens`, can be used to add additional symbols (like
    "__classify__") to a vocabulary.
  - The argument `do_lowercase` controls lower casing (automatically set for pretrained vocabularies).
  
  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`):
          Vocabulary file.
      merges_file (`str`):
          Merges file.
      do_lowercase (`bool`, *optional*, defaults to `False`):
          Controls lower casing.
      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.
      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>
  
      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.
      pad_token (`str`, *optional*, defaults to `"<pad>"`):
          The token used for padding, for example when batching sequences of different lengths.
      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.
      mask_token (`str`, *optional*, defaults to `"<special1>"`):
          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 `['<special0>', '<special1>', '<special2>', '<special3>', '<special4>', '<special5>', '<special6>', '<special7>', '<special8>', '<special9>']`):
          List of additional special tokens.
      lang2id (`Dict[str, int]`, *optional*):
          Dictionary mapping languages string identifiers to their IDs.
      id2lang (`Dict[int, str]`, *optional*):
          Dictionary mapping language IDs to their string identifiers.
class_docstr_tok: ["Construct","a","Flaubert","tokenizer",".","Based","on","Byte-Pair","Encoding",".","The","tokenization","process","is","the","following",":","-","Moses","preprocessing","and","tokenization",".","-","Normalizing","all","inputs","text",".","-","The","arguments","`","special_tokens","`","and","the","function","`","set_special_tokens","`",",","can","be","used","to","add","additional","symbols","(","like","``","__classify__","''",")","to","a","vocabulary",".","-","The","argument","`","do_lowercase","`","controls","lower","casing","(","automatically","set","for","pretrained","vocabularies",")",".","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","`",")",":","Vocabulary","file",".","merges_file","(","`","str","`",")",":","Merges","file",".","do_lowercase","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Controls","lower","casing",".","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",".","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",">","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",".","pad_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","pad",">","''","`",")",":","The","token","used","for","padding",",","for","example","when","batching","sequences","of","different","lengths",".","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",".","mask_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","special1",">","''","`",")",":","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","`","[","'","<","special0",">","'",",","'","<","special1",">","'",",","'","<","special2",">","'",",","'","<","special3",">","'",",","'","<","special4",">","'",",","'","<","special5",">","'",",","'","<","special6",">","'",",","'","<","special7",">","'",",","'","<","special8",">","'",",","'","<","special9",">","'","]","`",")",":","List","of","additional","special","tokens",".","lang2id","(","`","Dict","[","str",",","int","]","`",",","*","optional","*",")",":","Dictionary","mapping","languages","string","identifiers","to","their","IDs",".","id2lang","(","`","Dict","[","int",",","str","]","`",",","*","optional","*",")",":","Dictionary","mapping","language","IDs","to","their","string","identifiers","."]
code: def bpe(self, token):
      word = tuple(token[:-1]) + (token[-1] + "</w>",)
      if token in self.cache:
          return self.cache[token]
      pairs = get_pairs(word)
  
      if not pairs:
          return token + "</w>"
  
      while True:
          bigram = min(
              pairs,
              key=lambda pair: self.bpe_ranks.get(pair, float("inf")),
          )
          if bigram not in self.bpe_ranks:
              break
          first, second = bigram
          new_word = []
          i = 0
          while i < len(word):
              try:
                  j = word.index(first, i)
              except ValueError:
                  new_word.extend(word[i:])
                  break
              else:
                  new_word.extend(word[i:j])
                  i = j
  
              if (
                  word[i] == first
                  and i < len(word) - 1
                  and word[i + 1] == second
              ):
                  new_word.append(first + second)
                  i += 2
              else:
                  new_word.append(word[i])
                  i += 1
          new_word = tuple(new_word)
          word = new_word
          if len(word) == 1:
              break
          else:
              pairs = get_pairs(word)
      word = " ".join(word)
      if word == "\n  </w>":
          word = "\n</w>"
      self.cache[token] = word
      return word
  
imports: import json
  import os
  import re
  import unicodedata
  from typing import List, Optional, Tuple
  from ...tokenization_utils import PreTrainedTokenizer
  from ...utils import logging
label_desc: Use image node_id 9 for calling the FlaubertTokenizer obj's underlying member method code with example usage: obj.bpe(token) and returns: word, self, unknown