class_docstr: Runs pre-tokenization with Jieba segmentation tool. It is used in CPM models.
class_docstr_tok: ["Runs","pre-tokenization","with","Jieba","segmentation","tool",".","It","is","used","in","CPM","models","."]
docstr: Tokenize a string.
docstr_tok: ["Tokenize","a","string","."]
code: def _tokenize(self, text: str) -> List[str]:
      """Tokenize a string."""
      text = self.preprocess_text(text)
      pieces = self.sp_model.encode(text, out_type=str)
      new_pieces = []
      for piece in pieces:
          if (
              len(piece) > 1
              and piece[-1] == str(",")
              and piece[-2].isdigit()
          ):
              cur_pieces = self.sp_model.EncodeAsPieces(
                  piece[:-1].replace(SPIECE_UNDERLINE, "")
              )
              if (
                  piece[0] != SPIECE_UNDERLINE
                  and cur_pieces[0][0] == SPIECE_UNDERLINE
              ):
                  if len(cur_pieces[0]) == 1:
                      cur_pieces = cur_pieces[1:]
                  else:
                      cur_pieces[0] = cur_pieces[0][1:]
              cur_pieces.append(piece[-1])
              new_pieces.extend(cur_pieces)
          else:
              new_pieces.append(piece)
  
      return new_pieces
  
imports: import os
  import unicodedata
  from shutil import copyfile
  from typing import Any, Dict, List, Optional, Tuple
  import sentencepiece
  from ...tokenization_utils import AddedToken, PreTrainedTokenizer
  from ...utils import SPIECE_UNDERLINE, logging
label_desc: Use image node_id 7 for calling the CpmTokenizer obj's underlying member method code with example usage: obj._tokenize(text) and returns: new_pieces