class_docstr: Construct an MBART tokenizer.
  
  Adapted from [`RobertaTokenizer`] and [`XLNetTokenizer`]. Based on
  [SentencePiece](https://github.com/google/sentencepiece).
  
  The tokenization method is `<tokens> <eos> <language code>` for source language documents, and `<language code>
  <tokens> <eos>` for target language documents.
  
  Examples:
  
  ```python
  >>> from transformers import MBartTokenizer
  
  >>> tokenizer = MBartTokenizer.from_pretrained("facebook/mbart-large-en-ro", src_lang="en_XX", tgt_lang="ro_RO")
  >>> example_english_phrase = " UN Chief Says There Is No Military Solution in Syria"
  >>> expected_translation_romanian = "Şeful ONU declară că nu există o soluţie militară în Siria"
  >>> inputs = tokenizer(example_english_phrase, text_target=expected_translation_romanian, return_tensors="pt")
  ```
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>",
      tokenizer_file=None,
      src_lang=None,
      tgt_lang=None,
      sp_model_kwargs: Optional[Dict[str, Any]] = None,
      additional_special_tokens=None,
      **kwargs,
  ):
      # Mask token behave like a normal word, i.e. include the space before it
      mask_token = (
          AddedToken(mask_token, lstrip=True, normalized=False)
          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
  
      # 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()
      }
      _additional_special_tokens = list(self.lang_code_to_id.keys())
  
      if additional_special_tokens is not None:
          # Only add those special tokens if they are not already there.
          _additional_special_tokens.extend(
              [
                  t
                  for t in additional_special_tokens
                  if t not in _additional_special_tokens
              ]
          )
  
      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,
          tokenizer_file=None,
          src_lang=src_lang,
          tgt_lang=tgt_lang,
          additional_special_tokens=_additional_special_tokens,
          sp_model_kwargs=self.sp_model_kwargs,
          **kwargs,
      )
  
      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 MBartTokenizer object from inherited base classes: PreTrainedTokenizer with example: obj = MBartTokenizer(vocab_file, bos_token, eos_token, sep_token, cls_token, unk_token, pad_token, mask_token, tokenizer_file, src_lang, tgt_lang, sp_model_kwargs, additional_special_tokens)