class_docstr: Sentencepiecetokenizer https://github.com/google/sentencepiece.
  
      Args:
      model_path: path to sentence piece tokenizer model. To create the model use create_spt_model()
      special_tokens: either list of special tokens or dictionary of token name to token value
      legacy: when set to True, the previous behavior of the SentecePiece wrapper will be restored,
          including the possibility to add special tokens inside wrapper.
class_docstr_tok: ["Sentencepiecetokenizer","https",":","\/\/github.com\/google\/sentencepiece",".","Args",":","model_path",":","path","to","sentence","piece","tokenizer","model",".","To","create","the","model","use","create_spt_model","(",")","special_tokens",":","either","list","of","special","tokens","or","dictionary","of","token","name","to","token","value","legacy",":","when","set","to","True",",","the","previous","behavior","of","the","SentecePiece","wrapper","will","be","restored",",","including","the","possibility","to","add","special","tokens","inside","wrapper","."]
code: def add_special_tokens(self, special_tokens):
      if not self.legacy:
          raise AttributeError(
              "Special Token addition does not work when legacy is set to False."
          )
  
      if isinstance(special_tokens, list):
          for token in special_tokens:
              if (
                  self.tokenizer.piece_to_id(token)
                  == self.tokenizer.unk_id()
                  and token not in self.special_token_to_id
              ):
                  self.special_token_to_id[token] = self.vocab_size
                  self.id_to_special_token[self.vocab_size] = token
                  self.vocab_size += 1
      elif isinstance(special_tokens, dict):
          for token_name, token in special_tokens.items():
              setattr(self, token_name, token)
              if (
                  self.tokenizer.piece_to_id(token)
                  == self.tokenizer.unk_id()
                  and token not in self.special_token_to_id
              ):
                  self.special_token_to_id[token] = self.vocab_size
                  self.id_to_special_token[self.vocab_size] = token
                  self.vocab_size += 1
  
imports: import os
  from typing import Dict, List, Optional, Union
  import numpy
  import sentencepiece
  from nemo.collections.common.parts.utils import if_exist
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.utils import logging
label_desc: Use image node_id 9 for calling the SentencePieceTokenizer obj's underlying member method code with example usage: obj.add_special_tokens(special_tokens) without return types