class_docstr: Tests parameterized embedder.
      
class_docstr_tok: ["Tests","parameterized","embedder","."]
docstr: Tests :class:`texar.tf.modules.PositionEmbedder`.
          
docstr_tok: ["Tests",":","class",":","`","texar.tf.modules.PositionEmbedder","`","."]
code: def _test_position_embedder(self, hparams):
      """Tests :class:`texar.tf.modules.PositionEmbedder`."""
      pos_size = 100
      embedder = PositionEmbedder(
          position_size=pos_size, hparams=hparams
      )
      inputs = tf.ones([64, 16], dtype=tf.int32)
      outputs = embedder(inputs)
  
      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(emb_dim, hparams_dim)
      self.assertEqual(embedder.position_size, 100)
      self.assertEqual(len(embedder.trainable_variables), 1)
  
      seq_length = tf.random_uniform(
          [64], maxval=pos_size, dtype=tf.int32
      )
      outputs = embedder(sequence_length=seq_length)
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          outputs_, max_seq_length = sess.run(
              [outputs, tf.reduce_max(seq_length)],
              feed_dict={global_mode(): tf.estimator.ModeKeys.TRAIN},
          )
          self.assertEqual(
              outputs_.shape, (64, max_seq_length) + tuple(emb_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 2 for calling the EmbedderTest obj's underlying member method code with example usage: obj._test_position_embedder(hparams) without return types