class_docstr: Tests parameterized embedder.
      
class_docstr_tok: ["Tests","parameterized","embedder","."]
docstr: Tests :class:`texar.tf.modules.WordEmbedder`.
          
docstr_tok: ["Tests",":","class",":","`","texar.tf.modules.WordEmbedder","`","."]
code: def _test_word_embedder(self, hparams):
      """Tests :class:`texar.tf.modules.WordEmbedder`."""
      embedder = WordEmbedder(vocab_size=100, hparams=hparams)
  
      inputs = tf.ones([64, 16], dtype=tf.int32)
      outputs = embedder(inputs)
  
      inputs_soft = tf.ones(
          [64, 16, embedder.vocab_size], dtype=tf.float32
      )
      outputs_soft = embedder(soft_ids=inputs_soft)
  
      emb_dim = embedder.dim
      if not isinstance(emb_dim, (list, tuple)):
          emb_dim = [emb_dim]
  
      hparams_dim = hparams["dim"]
      if not isinstance(hparams["dim"], (list, tuple)):
          hparams_dim = [hparams["dim"]]
  
      self.assertEqual(outputs.shape, [64, 16] + emb_dim)
      self.assertEqual(outputs_soft.shape, [64, 16] + emb_dim)
      self.assertEqual(emb_dim, hparams_dim)
      self.assertEqual(embedder.vocab_size, 100)
      self.assertEqual(len(embedder.trainable_variables), 1)
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          outputs_, outputs_soft_ = sess.run(
              [outputs, outputs_soft],
              feed_dict={global_mode(): tf.estimator.ModeKeys.TRAIN},
          )
          self.assertEqual(outputs_.shape, (64, 16) + tuple(emb_dim))
          self.assertEqual(
              outputs_soft_.shape, (64, 16) + tuple(emb_dim)
          )
  
      # Tests unknown input shapes
      inputs = tf.placeholder(dtype=tf.int64, shape=[None, None])
      outputs = embedder(inputs)
      self.assertEqual(len(outputs.get_shape()), 2 + len(hparams_dim))
  
      inputs_soft = tf.placeholder(
          dtype=tf.int64, shape=[None, None, None]
      )
      outputs_soft = embedder(soft_ids=inputs_soft)
      self.assertEqual(
          len(outputs_soft.get_shape()), 2 + len(hparams_dim)
      )
  
file_path: texar/tests/modules/embedders/embedders_test.py
imports: import numpy
  import tensorflow
  from texar.tf.modules.embedders.embedders import WordEmbedder
  from texar.tf.modules.embedders.position_embedders import PositionEmbedder
  from texar.tf.context import global_mode
label_desc: Use image node_id 1 for calling the EmbedderTest obj's underlying member method code with example usage: obj._test_word_embedder(hparams) without return types