code: def _trim_and_pad(t, length):
    
    t = t[:length]
    paddings = [[0, length - tf.shape(t)[0]]] + [[0, 0]]*(t.get_shape().ndims - 1)
    t = tf.pad(t, paddings)
    return t
docs: Trim/pad to the first axis of t to be of size length.
  
    Args:
      t: a tf.Tensor
      length: an integer
    Returns:
      a tf.Tensor