class_docstr: SentencePiece subword transform class.
docstr: Apply subword sampling or deterministic subwording
docstr_tok: ["Apply","subword","sampling","or","deterministic","subwording"]
code: def tokenize_string(self, string, side="src", is_train=False):
      """Apply subword sampling or deterministic subwording"""
      sp_model = self.load_models[side]
      nbest_size = (
          self.tgt_subword_nbest
          if side == "tgt"
          else self.src_subword_nbest
      )
      if is_train is False or nbest_size in [0, 1]:
          # derterministic subwording
          tokens = sp_model.encode(string, out_type=str)
      else:
          # subword sampling when nbest_size > 1 or -1
          # alpha should be 0.0 < alpha < 1.0
          alpha = (
              self.tgt_subword_alpha
              if side == "tgt"
              else self.src_subword_alpha
          )
          tokens = sp_model.encode(
              string,
              out_type=str,
              enable_sampling=True,
              alpha=alpha,
              nbest_size=nbest_size,
          )
      return tokens
  
imports: import re
  from onmt.utils.logging import logger
  from onmt.transforms import register_transform
  from .transform import Transform, ObservableStats
  from onmt.constants import DefaultTokens
label_desc: Use image node_id 4 for calling the SentencePieceTransform obj's underlying member method code with example usage: obj.tokenize_string(string, side, is_train) and returns: tokens