code: def main_restore_embedding_layer():
      """How to use Embedding layer, and how to convert IDs to vector,
      IDs to words, etc.
      """
      # Step 1: Build the embedding matrix and load the existing embedding matrix.
      vocabulary_size = 50000
      embedding_size = 128
      model_file_name = "model_word2vec_50k_128"
      batch_size = None
  
      if not os.path.exists(model_file_name + ".npy"):
          raise Exception(
              "Pretrained embedding matrix not found. "
              "Hint: Please pre-train the default model in "
              "`examples/text_word_embedding/tutorial_word2vec_basic.py`."
          )
  
      print("Load existing embedding matrix and dictionaries")
      all_var = tl.files.load_npy_to_any(name=model_file_name + ".npy")
      data = all_var["data"]
      count = all_var["count"]
      dictionary = all_var["dictionary"]
      reverse_dictionary = all_var["reverse_dictionary"]
  
      tl.nlp.save_vocab(count, name="vocab_" + model_file_name + ".txt")
  
      del all_var, data, count
  
      class Embedding_Model(Model):
          def __init__(self):
              super(Embedding_Model, self).__init__()
              self.embedding = Embedding(
                  vocabulary_size, embedding_size
              )
  
          def forward(self, inputs):
              return self.embedding(inputs)
  
      model = Embedding_Model()
      model.eval()
  
      # TODO: assign certain parameters to model
      model.load_weights(
          model_file_name + ".hdf5", skip=True, in_order=False
      )
  
      # Step 2: Input word(s), output the word vector(s).
      word = "hello"
      word_id = dictionary[word]
      print("word_id:", word_id)
  
      words = ["i", "am", "tensor", "layer"]
      word_ids = tl.nlp.words_to_word_ids(words, dictionary, _UNK)
      context = tl.nlp.word_ids_to_words(word_ids, reverse_dictionary)
      print("word_ids:", word_ids)
      print("context:", context)
  
      vector = model(word_id)
      print("vector:", vector.shape)
      print(vector)
  
      vectors = model(word_ids)
      print("vectors:", vectors.shape)
      print(vectors)
  
file_path: TensorLayer/examples/text_generation/tutorial_generate_text.py
imports: import os
  import re
  import time
  import nltk
  import numpy
  import tensorflow
  import tensorlayer
  from tensorlayer.layers import *
  from tensorlayer.models import Model
label_desc: Use image node_id 4 for calling a global function with example usage: main_restore_embedding_layer() and returns: self