def pad_to_length(tensor, target_length):
  """Pads a 1-D Tensor with zeros to the target length."""
  pad_amt = target_length - tf.size(tensor)
  # Assert that pad_amt is non-negative.
  assert_op = tf.Assert(pad_amt >= 0,
                        ["\nERROR: len(tensor) > target_length.", pad_amt])
  with tf.control_dependencies([assert_op]):
    padded = tf.pad(tensor, [[0, pad_amt]])
    padded.set_shape([target_length])
    return padded
Pads a 1-D Tensor with zeros to the target length.
language/conpono/reconstruct/preprocess.py