code: def encode_pieces(spm_model, text, return_unicode=True, sample=False):
      """turn sentences into word pieces."""
      # liujiaxiang: add for ernie-albert, mainly consider for “/”/‘/’/— causing too many unk
      text = clean_text(text)
  
      if not sample:
          pieces = spm_model.EncodeAsPieces(text)
      else:
          pieces = spm_model.SampleEncodeAsPieces(text, 64, 0.1)
  
      return pieces
  
imports: import collections
  import sentencepiece
  import unicodedata
  from .args import str2bool
label_desc: Use image node_id 3 for calling a global function with example usage: encode_pieces(spm_model, text, return_unicode, sample) and returns: pieces