(tensor, total_size, position)
return tf.concat([pad_before, tensor, pad_after], axis=0)
Pad tensor with zeros along its first axis.

  The output will have first dimension total_size, and
  tensor will appear at position position.

  Args:
    tensor: tensor to pad.
    total_size: the output size.
    position: where in the output tensor should appear.

  Returns:
    output: The padded tensor.
Pad tensor with zeros along its first axis.
Pad tensor with zeros along its first axis .
def _pad(tensor, total_size, position):
  """Pad tensor with zeros along its first axis.

  The output will have first dimension total_size, and
  tensor will appear at position position.

  Args:
    tensor: tensor to pad.
    total_size: the output size.
    position: where in the output tensor should appear.

  Returns:
    output: The padded tensor.
  """
  shape_rest = tf.shape(tensor)[1:]
  after_dim = total_size - position - tf.shape(tensor)[0]
  pad_before = tf.zeros(
      tf.concat([[position], shape_rest], axis=0), dtype=tensor.dtype)
  pad_after = tf.zeros(
      tf.concat([[after_dim], shape_rest], axis=0), dtype=tensor.dtype)
  return tf.concat([pad_before, tensor, pad_after], axis=0)
def _pad ( tensor , total_size , position ) : shape_rest = tf . shape ( tensor ) [ 1 : ] after_dim = total_size - position - tf . shape ( tensor ) [ 0 ] pad_before = tf . zeros ( tf . concat ( [ [ position ] , shape_rest ] , axis = 0 ) , dtype = tensor . dtype ) pad_after = tf . zeros ( tf . concat ( [ [ after_dim ] , shape_rest ] , axis = 0 ) , dtype = tensor . dtype ) return tf . concat ( [ pad_before , tensor , pad_after ] , axis = 0 )