class_docstr: Helper to remove padding from a tensor before sending to the experts.
  The padding is computed for one reference tensor containing the padding mask
  and then can be applied to any other tensor of shape [dim_origin,...].
  
  Example::
  
          input = [
              [tok1, tok2],
              [tok3, tok4],
              [0, 0],
              [0, 0],
              [tok5, tok6],
              [0, 0],
          ]
          output = [
              [tok1, tok2],
              [tok3, tok4],
              [tok5, tok6],
          ]
docstr: Remove padding from the given tensor.
  
  Args:
      x: A Tensor of shape [dim_origin,...]
  
  Returns:
      A tensor of shape [dim_compressed,...] with dim_compressed
      <= dim_origin
code: def remove(self, x):
      """Remove padding from the given tensor.
  
      Args:
          x: A Tensor of shape [dim_origin,...]
  
      Returns:
          A tensor of shape [dim_compressed,...] with dim_compressed
          <= dim_origin
      """
      with tf.name_scope("pad_reduce/remove"):
          x_shape = x.get_shape().as_list()
          x = tf.gather_nd(
              x,
              indices=self.nonpad_ids,
          )
          # if not context.in_eager_mode():
          # This is a hack but for some reason, gather_nd return a tensor of
          # undefined shape, so the shape is set up manually
          x.set_shape([None] + x_shape[1:])
      return x
  
file_path: texar/texar/tf/utils/transformer_utils.py
imports: import tensorflow
  from tensorflow_probability import distributions
label_desc: Use image node_id 2 for calling the PadRemover obj's underlying member method code with example usage: obj.remove(x) and returns: x