code: def text2tokens(text, lexicon_fn):
      phonemes = load_phonemes_set()
      lexicon = load_lexicon(lexicon_fn)
  
      words = text.strip().lower().split()
      tokens = [FLAGS.sil_index]
      for word in words:
          if word in FLAGS.special_phonemes:
              tokens.append(phonemes.index(word))
          elif word in lexicon:
              p = lexicon[word]
              p = p.split()
              p = [phonemes.index(pp) for pp in p]
              tokens.extend(p)
              tokens.append(FLAGS.word_end_index)
          else:
              for p in word:
                  if p in phonemes:
                      tokens.append(phonemes.index(p))
              tokens.append(FLAGS.word_end_index)
      tokens.append(FLAGS.sil_index)  # silence
      return tokens
  
file_path: underthesea/underthesea/pipeline/say/viettts_/nat/text2mel.py
imports: import pickle
  from argparse import ArgumentParser
  from pathlib import Path
  import haiku
  import jax
  import jax.numpy
  import matplotlib.pyplot
  import numpy
  from .config import FLAGS, DurationInput
  from .data_loader import load_phonemes_set
  from .model import AcousticModel, DurationModel
label_desc: Use image node_id 3 for calling a global function with example usage: text2tokens(text, lexicon_fn) and returns: tokens