code: def init_trainable_embedding(
      embedding_path, word_id_dict, embed_dim=300
  ):
      word_embed_model = load_glove_model(embedding_path, embed_dim)
      assert word_embed_model["pool"].shape[1] == embed_dim
      embedding = (
          np.random.random([len(word_id_dict), embed_dim]).astype(
              np.float32
          )
          / 2.0
          - 0.25
      )
      embedding[0] = np.zeros(embed_dim)  # PAD
      embedding[1] = (np.random.rand(embed_dim) - 0.5) / 2  # UNK
      for word in sorted(word_id_dict.keys()):
          idx = word_id_dict[word]
          if idx == 0 or idx == 1:
              continue
          if word in word_embed_model["mapping"]:
              embedding[idx] = word_embed_model["pool"][
                  word_embed_model["mapping"][word]
              ]
          else:
              embedding[idx] = np.random.rand(embed_dim) / 2.0 - 0.25
      return embedding
  
imports: import logging
  import os
  import pickle
  from collections import Counter
  import numpy
  import torch
  from torch.utils import data
label_desc: Use image node_id 9 for calling a global function with example usage: init_trainable_embedding(embedding_path, word_id_dict, embed_dim) and returns: embedding