class_docstr: Simple word embedder that maps indexes into embeddings. The indexes
  can be soft (e.g., distributions over vocabulary).
  
  Either :attr:`init_value` or :attr:`vocab_size` is required. If both are
  given, there must be ``init_value.shape[0]==vocab_size``.
  
  Args:
      init_value (optional): A Tensor or numpy array that contains the
          initial value of embeddings. It is typically of shape
          ``[vocab_size] + embedding-dim``. Embedding can have dimensionality
          > 1.
  
          If `None`, embedding is initialized as specified in
          ``hparams["initializer"]``. Otherwise, the
          ``"initializer"`` and ``"dim"`` hyperparameters in
          :attr:`hparams` are ignored.
      vocab_size (int, optional): The vocabulary size. Required if
          :attr:`init_value` is not given.
      hparams (dict, optional): Embedder hyperparameters. Missing
          hyperparamerter will be set to default values. See
          :meth:`default_hparams` for the hyperparameter structure and
          default values.
  
  See :meth:`_build` for the inputs and outputs of the embedder.
  
  Example:
  
      .. code-block:: python
  
          ids = tf.random_uniform(shape=[32, 10], maxval=10, dtype=tf.int64)
          soft_ids = tf.random_uniform(shape=[32, 10, 100])
  
          embedder = WordEmbedder(vocab_size=100, hparams={'dim': 256})
          ids_emb = embedder(ids=ids) # shape: [32, 10, 256]
          soft_ids_emb = embedder(soft_ids=soft_ids) # shape: [32, 10, 256]
  
      .. code-block:: python
  
          # Use with Texar data module
          hparams={
              'dataset': {
                  'embedding_init': {'file': 'word2vec.txt'}
                  ...
              },
          }
          data = MonoTextData(data_params)
          iterator = DataIterator(data)
          batch = iterator.get_next()
  
          # Use data vocab size
          embedder_1 = WordEmbedder(vocab_size=data.vocab.size)
          emb_1 = embedder_1(batch['text_ids'])
  
          # Use pre-trained embedding
          embedder_2 = WordEmbedder(init_value=data.embedding_init_value)
          emb_2 = embedder_2(batch['text_ids'])
  
  
  .. document private functions
  .. automethod:: _build
class_docstr_tok: ["Simple","word","embedder","that","maps","indexes","into","embeddings",".","The","indexes","can","be","soft","(","e.g.",",","distributions","over","vocabulary",")",".","Either",":","attr",":","`","init_value","`","or",":","attr",":","`","vocab_size","`","is","required",".","If","both","are","given",",","there","must","be","``","init_value.shape","[","0","]","==vocab_size","``",".","Args",":","init_value","(","optional",")",":","A","Tensor","or","numpy","array","that","contains","the","initial","value","of","embeddings",".","It","is","typically","of","shape","``","[","vocab_size","]","+","embedding-dim","``",".","Embedding","can","have","dimensionality",">","1",".","If","`","None","`",",","embedding","is","initialized","as","specified","in","``","hparams","[","``","initializer","''","]","``",".","Otherwise",",","the","``","``","initializer","''","``","and","``","``","dim","''","``","hyperparameters","in",":","attr",":","`","hparams","`","are","ignored",".","vocab_size","(","int",",","optional",")",":","The","vocabulary","size",".","Required","if",":","attr",":","`","init_value","`","is","not","given",".","hparams","(","dict",",","optional",")",":","Embedder","hyperparameters",".","Missing","hyperparamerter","will","be","set","to","default","values",".","See",":","meth",":","`","default_hparams","`","for","the","hyperparameter","structure","and","default","values",".","See",":","meth",":","`","_build","`","for","the","inputs","and","outputs","of","the","embedder",".","Example",":","..","code-block",":",":","python","ids","=","tf.random_uniform","(","shape=","[","32",",","10","]",",","maxval=10",",","dtype=tf.int64",")","soft_ids","=","tf.random_uniform","(","shape=","[","32",",","10",",","100","]",")","embedder","=","WordEmbedder","(","vocab_size=100",",","hparams=","{","'dim","'",":","256","}",")","ids_emb","=","embedder","(","ids=ids",")","#","shape",":","[","32",",","10",",","256","]","soft_ids_emb","=","embedder","(","soft_ids=soft_ids",")","#","shape",":","[","32",",","10",",","256","]","..","code-block",":",":","python","#","Use","with","Texar","data","module","hparams=","{","'dataset","'",":","{","'embedding_init","'",":","{","'file","'",":","'word2vec.txt","'","}","...","}",",","}","data","=","MonoTextData","(","data_params",")","iterator","=","DataIterator","(","data",")","batch","=","iterator.get_next","(",")","#","Use","data","vocab","size","embedder_1","=","WordEmbedder","(","vocab_size=data.vocab.size",")","emb_1","=","embedder_1","(","batch","[","'text_ids","'","]",")","#","Use","pre-trained","embedding","embedder_2","=","WordEmbedder","(","init_value=data.embedding_init_value",")","emb_2","=","embedder_2","(","batch","[","'text_ids","'","]",")","..","document","private","functions","..","automethod",":",":","_build"]
docstr: The embedding dimension.
          
docstr_tok: ["The","embedding","dimension","."]
code: def dim(self):
      r"""The embedding dimension."""
      return self._dim
  
file_path: texar/texar/tf/modules/embedders/embedders.py
imports: import tensorflow
  from texar.tf.modules.embedders.embedder_base import EmbedderBase
  from texar.tf.modules.embedders import embedder_utils
  from texar.tf.utils.mode import is_train_mode
  from texar.tf.utils.shapes import get_rank
label_desc: Use image node_id 5 for calling the WordEmbedder obj's underlying member method code with example usage: obj.dim() and returns: self