class_docstr: Embedding class that loads token embedding vectors from file. Token
  embeddings not in the embedding file are initialized as specified in
  :attr:`hparams`.
  
  Args:
      vocab (dict): A dictionary that maps token strings to integer index.
      read_fn: Callable that takes `(filename, vocab, word_vecs)` and
          returns the updated `word_vecs`. E.g.,
          :func:`~texar.tf.data.embedding.load_word2vec` and
          :func:`~texar.tf.data.embedding.load_glove`.
class_docstr_tok: ["Embedding","class","that","loads","token","embedding","vectors","from","file",".","Token","embeddings","not","in","the","embedding","file","are","initialized","as","specified","in",":","attr",":","`","hparams","`",".","Args",":","vocab","(","dict",")",":","A","dictionary","that","maps","token","strings","to","integer","index",".","read_fn",":","Callable","that","takes","`","(","filename",",","vocab",",","word_vecs",")","`","and","returns","the","updated","`","word_vecs","`",".","E.g.",",",":","func",":","`","~texar.tf.data.embedding.load_word2vec","`","and",":","func",":","`","~texar.tf.data.embedding.load_glove","`","."]
code: def __init__(self, vocab, hparams=None):
      self._hparams = HParams(hparams, self.default_hparams())
  
      # Initialize embeddings
      init_fn_kwargs = self._hparams.init_fn.kwargs.todict()
      if "shape" in init_fn_kwargs or "size" in init_fn_kwargs:
          raise ValueError(
              "Argument 'shape' or 'size' must not be "
              "specified. They are inferred automatically."
          )
      init_fn = utils.get_function(
          self._hparams.init_fn.type,
          ["numpy.random", "numpy", "texar.tf.custom"],
      )
  
      try:
          self._word_vecs = init_fn(
              size=[len(vocab), self._hparams.dim], **init_fn_kwargs
          )
      except TypeError:
          self._word_vecs = init_fn(
              shape=[len(vocab), self._hparams.dim], **init_fn_kwargs
          )
  
      # Optionally read embeddings from file
      if self._hparams.file is not None and self._hparams.file != "":
          read_fn = utils.get_function(
              self._hparams.read_fn,
              [
                  "texar.tf.data.embedding",
                  "texar.tf.data",
                  "texar.tf.custom",
              ],
          )
  
          self._word_vecs = read_fn(
              self._hparams.file, vocab, self._word_vecs
          )
  
file_path: texar/texar/tf/data/embedding.py
imports: import tensorflow
  from tensorflow import gfile
  import numpy
  from texar.tf.utils import utils
  from texar.tf.hyperparams import HParams
label_desc: Use image node_id 1 to create a new Embedding object from inherited base classes: object with example: obj = Embedding(vocab, hparams)