class_docstr: Tests shape-related utility functions.
      
docstr: Tests :func:`texar.tf.utils.shapes.varlength_concat`.
code: def test_varlength_concat(self):
      """
      Tests :func:`texar.tf.utils.shapes.varlength_concat`.
      """
      # 2D
      x = np.asarray(
          [[1, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]], dtype=np.int32
      )
      x_length = np.asarray([2, 1, 4], dtype=np.int32)
      y = np.asarray(
          [[2, 2, 2, 0], [2, 2, 2, 2], [2, 2, 0, 0]], dtype=np.int32
      )
  
      z_true = np.asarray(
          [
              [1, 1, 2, 2, 2, 0, 0, 0],
              [1, 2, 2, 2, 2, 0, 0, 0],
              [1, 1, 1, 1, 2, 2, 0, 0],
          ],
          dtype=np.int32,
      )
  
      # py
      z = shapes.varlength_concat_py(x, y, x_length)
      np.testing.assert_array_equal(z, z_true)
  
      # tf
      z = shapes.varlength_concat(x, y, x_length)
      with self.test_session() as sess:
          z_ = sess.run(z)
          np.testing.assert_array_equal(z_, z_true)
  
      # 3D
      x = np.asarray(
          [
              [[1], [1], [0], [0]],
              [[1], [0], [0], [0]],
              [[1], [1], [1], [1]],
          ],
          dtype=np.int32,
      )
      x_length = [2, 1, 4]
      y = np.asarray(
          [
              [[2], [2], [2], [0]],
              [[2], [2], [2], [2]],
              [[2], [2], [0], [0]],
          ],
          dtype=np.int32,
      )
      z_true = np.asarray(
          [
              [[1], [1], [2], [2], [2], [0], [0], [0]],
              [[1], [2], [2], [2], [2], [0], [0], [0]],
              [[1], [1], [1], [1], [2], [2], [0], [0]],
          ],
          dtype=np.int32,
      )
  
      # py
      z = shapes.varlength_concat_py(x, y, x_length)
      np.testing.assert_array_equal(z, z_true)
  
      # tf
      z = shapes.varlength_concat(x, y, x_length)
      with self.test_session() as sess:
          z_ = sess.run(z)
          np.testing.assert_array_equal(z_, z_true)
  
file_path: texar/tests/utils/shapes_test.py
imports: import numpy
  import tensorflow
  from texar.tf.utils import shapes
label_desc: Use image node_id 4 for calling the ShapesTest obj's underlying member method code with example usage: obj.test_varlength_concat() without return types