code: def tokenize(self, text):
      if len(text) == 0:
          return []
      if six.PY3 and not isinstance(text, six.string_types):
          text = text.decode(self.encoding)
      if six.PY2 and isinstance(text, str):
          text = text.decode(self.encoding)
  
      res = []
      for match in self.pat.finditer(text):
          match_group = match.group(0)
          if match.groups()[-1]:
              if self.lower:
                  match_group = match_group.lower()
              words, _ = _wordpiece(
                  match_group,
                  vocab=self.vocab,
                  unk_token=self.unk_token,
                  prefix=self.prefix,
                  sentencepiece_prefix=self.sentencepiece_prefix,
              )
          else:
              words = [match_group]
          res += words
      return res
  
file_path: PaddleHub/modules/text/text_generation/reading_pictures_writing_poems_for_midautumn/MidAutumnPoetry/model/tokenizing_ernie.py
imports: import six
  import re
  import logging
  from functools import partial
  import numpy
  import io
label_desc: Use image node_id 2 for calling the ErnieTokenizer obj's underlying member method code with example usage: obj.tokenize(text) and returns: res, list