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 __init__(
      self,
      model_path: str,
      special_tokens: Optional[Union[Dict[str, str], List[str]]] = None,
      legacy: bool = False,
  ):
      if not model_path or not os.path.exists(model_path):
          raise ValueError(f"model_path: {model_path} is invalid")
      self.tokenizer = sentencepiece.SentencePieceProcessor()
      self.tokenizer.Load(model_path)
  
      self.original_vocab_size = self.tokenizer.get_piece_size()
      self.vocab_size = self.tokenizer.get_piece_size()
      self.legacy = legacy
      self.special_token_to_id = {}
      self.id_to_special_token = {}
      if special_tokens:
          if not self.legacy:
              raise ValueError(
                  "Special tokens must be None when legacy is set to False. Provide special tokens at train time."
              )
          self.add_special_tokens(special_tokens)
      self.space_sensitive = self.text_to_tokens(
          "x y"
      ) != self.text_to_tokens("x") + self.text_to_tokens("y")
  
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 1 to create a new SentencePieceTokenizer object from inherited base classes: TokenizerSpec with example: obj = SentencePieceTokenizer(model_path, special_tokens, legacy)