class_docstr: Construct a MBart50 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`):
          Path to the vocabulary file.
      src_lang (`str`, *optional*):
          A string representing the source language.
      tgt_lang (`str`, *optional*):
          A string representing the target language.
      eos_token (`str`, *optional*, defaults to `"</s>"`):
          The end of sequence token.
      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.
      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.
  
  Examples:
  
  ```python
  >>> from transformers import MBart50Tokenizer
  
  >>> tokenizer = MBart50Tokenizer.from_pretrained("facebook/mbart-large-50", src_lang="en_XX", tgt_lang="ro_RO")
  >>> src_text = " UN Chief Says There Is No Military Solution in Syria"
  >>> tgt_text = "Şeful ONU declară că nu există o soluţie militară în Siria"
  >>> model_inputs = tokenizer(src_text, text_target=tgt_text, return_tensors="pt")
  >>> # model(**model_inputs) should work
  ```
class_docstr_tok: ["Construct","a","MBart50","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","`",")",":","Path","to","the","vocabulary","file",".","src_lang","(","`","str","`",",","*","optional","*",")",":","A","string","representing","the","source","language",".","tgt_lang","(","`","str","`",",","*","optional","*",")",":","A","string","representing","the","target","language",".","eos_token","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","<","\/s",">","''","`",")",":","The","end","of","sequence","token",".","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",".","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",".","Examples",":","``","`","python",">",">",">","from","transformers","import","MBart50Tokenizer",">",">",">","tokenizer","=","MBart50Tokenizer.from_pretrained","(","``","facebook\/mbart-large-50","''",",","src_lang=","''","en_XX","''",",","tgt_lang=","''","ro_RO","''",")",">",">",">","src_text","=","``","UN","Chief","Says","There","Is","No","Military","Solution","in","Syria","''",">",">",">","tgt_text","=","``","\u015eeful","ONU","declar\u0103","c\u0103","nu","exist\u0103","o","solu\u0163ie","militar\u0103","\u00een","Siria","''",">",">",">","model_inputs","=","tokenizer","(","src_text",",","text_target=tgt_text",",","return_tensors=","''","pt","''",")",">",">",">","#","model","(","*","*","model_inputs",")","should","work","``","`"]
code: def __init__(
      self,
      vocab_file,
      src_lang=None,
      tgt_lang=None,
      eos_token="</s>",
      sep_token="</s>",
      cls_token="<s>",
      unk_token="<unk>",
      pad_token="<pad>",
      mask_token="<mask>",
      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)
          if isinstance(mask_token, str)
          else mask_token
      )
  
      self.sp_model_kwargs = (
          {} if sp_model_kwargs is None else sp_model_kwargs
      )
  
      kwargs["additional_special_tokens"] = kwargs.get(
          "additional_special_tokens", []
      )
      kwargs["additional_special_tokens"] += [
          code
          for code in FAIRSEQ_LANGUAGE_CODES
          if code not in kwargs["additional_special_tokens"]
      ]
  
      super().__init__(
          src_lang=src_lang,
          tgt_lang=tgt_lang,
          eos_token=eos_token,
          unk_token=unk_token,
          sep_token=sep_token,
          cls_token=cls_token,
          pad_token=pad_token,
          mask_token=mask_token,
          sp_model_kwargs=self.sp_model_kwargs,
          **kwargs,
      )
  
      self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
      self.sp_model.Load(str(vocab_file))
      self.vocab_file = vocab_file
  
      # Original fairseq vocab and spm vocab must be "aligned":
      # Vocab    |    0    |    1    |   2    |    3    |  4  |  5  |  6  |   7   |   8   |  9
      # -------- | ------- | ------- | ------ | ------- | --- | --- | --- | ----- | ----- | ----
      # fairseq  | '<s>'   | '<pad>' | '</s>' | '<unk>' | ',' | '.' | '▁' | 's'   | '▁de' | '-'
      # spm      | '<unk>' | '<s>'   | '</s>' | ','     | '.' | '▁' | 's' | '▁de' | '-'   | '▁a'
  
      # Mimic fairseq token-to-id alignment for the first 4 token
      self.fairseq_tokens_to_ids = {
          "<s>": 0,
          "<pad>": 1,
          "</s>": 2,
          "<unk>": 3,
      }
  
      # The first "real" token "," has position 4 in the original fairseq vocab and position 3 in the spm vocab
      self.fairseq_offset = 1
  
      self.sp_model_size = len(self.sp_model)
      self.lang_code_to_id = {
          code: self.sp_model_size + i + self.fairseq_offset
          for i, code in enumerate(FAIRSEQ_LANGUAGE_CODES)
      }
      self.id_to_lang_code = {
          v: k for k, v in self.lang_code_to_id.items()
      }
      self.fairseq_tokens_to_ids["<mask>"] = (
          len(self.sp_model)
          + len(self.lang_code_to_id)
          + self.fairseq_offset
      )
  
      self.fairseq_tokens_to_ids.update(self.lang_code_to_id)
      self.fairseq_ids_to_tokens = {
          v: k for k, v in self.fairseq_tokens_to_ids.items()
      }
  
      self._src_lang = src_lang if src_lang is not None else "en_XX"
      self.cur_lang_code_id = self.lang_code_to_id[self._src_lang]
      self.tgt_lang = tgt_lang
      self.set_src_lang_special_tokens(self._src_lang)
  
imports: import os
  from shutil import copyfile
  from typing import Any, Dict, List, Optional, Tuple
  import sentencepiece
  from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer
  from ...utils import logging
label_desc: Use image node_id 1 to create a new MBart50Tokenizer object from inherited base classes: PreTrainedTokenizer with example: obj = MBart50Tokenizer(vocab_file, src_lang, tgt_lang, eos_token, sep_token, cls_token, unk_token, pad_token, mask_token, sp_model_kwargs)