code: def load_embed_txt(embed_file):
      """Load embed_file into a python dictionary.
  
      Note: the embed_file should be a Glove/word2vec formatted txt file. Assuming
      Here is an exampe assuming embed_size=5:
  
      the -0.071549 0.093459 0.023738 -0.090339 0.056123
      to 0.57346 0.5417 -0.23477 -0.3624 0.4037
      and 0.20327 0.47348 0.050877 0.002103 0.060547
  
      For word2vec format, the first line will be: <num_words> <emb_size>.
  
      Args:
        embed_file: file path to the embedding file.
      Returns:
        a dictionary that maps word to vector, and the size of embedding dimensions.
      """
      emb_dict = dict()
      emb_size = None
  
      is_first_line = True
      with codecs.getreader("utf-8")(
          tf.gfile.GFile(embed_file, "rb")
      ) as f:
          for line in f:
              tokens = line.rstrip().split(" ")
              if is_first_line:
                  is_first_line = False
                  if len(tokens) == 2:  # header line
                      emb_size = int(tokens[1])
                      continue
              word = tokens[0]
              vec = list(map(float, tokens[1:]))
              emb_dict[word] = vec
              if emb_size:
                  if emb_size != len(vec):
                      utils.print_out(
                          "Ignoring %s since embeding size is inconsistent."
                          % word
                      )
                      del emb_dict[word]
              else:
                  emb_size = len(vec)
      return emb_dict, emb_size
  
file_path: nlp-architect/examples/sparse_gnmt/gnmt/utils/vocab_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import codecs
  import os
  import tensorflow
  from tensorflow.python.ops import lookup_ops
  from .None import misc_utils
label_desc: Use image node_id 6 for calling a global function with example usage: load_embed_txt(embed_file) and returns: emb_dict,  emb_size