def pad_batch(batch, batch_size):
    'Resize batch to a given size, tiling present samples over missing.\n\n  Example:\n    Suppose batch_size is 5, batch is [1, 2].\n    Then the return value is [1, 2, 1, 2, 1].\n\n  Args:\n    batch: An ndarray with first dimension size <= batch_size.\n    batch_size: Desired size for first dimension.\n\n  Returns:\n    An ndarray of the same shape, except first dimension has\n    the desired size.\n  '
    padded = np.zeros(((batch_size,) + batch.shape[1:]), dtype=batch.dtype)
    next_idx = 0
    while (next_idx < batch_size):
        fill_len = min(batch.shape[0], (batch_size - next_idx))
        padded[next_idx:(next_idx + fill_len)] = batch[:fill_len]
        next_idx += fill_len
    return padded
Resize batch to a given size, tiling present samples over missing.

Example:
  Suppose batch_size is 5, batch is [1, 2].
  Then the return value is [1, 2, 1, 2, 1].

Args:
  batch: An ndarray with first dimension size <= batch_size.
  batch_size: Desired size for first dimension.

Returns:
  An ndarray of the same shape, except first dimension has
  the desired size.
def pad_batch(batch, batch_size):
    'Resize batch to a given size, tiling present samples over missing.\n\n  Example:\n    Suppose batch_size is 5, batch is [1, 2].\n    Then the return value is [1, 2, 1, 2, 1].\n\n  Args:\n    batch: An ndarray with first dimension size <= batch_size.\n    batch_size: Desired size for first dimension.\n\n  Returns:\n    An ndarray of the same shape, except first dimension has\n    the desired size.\n  '
    padded = np.zeros(((batch_size,) + batch.shape[1:]), dtype=batch.dtype)
    next_idx = 0
    while (next_idx < batch_size):
        fill_len = min(batch.shape[0], (batch_size - next_idx))
        padded[next_idx:(next_idx + fill_len)] = batch[:fill_len]
        next_idx += fill_len
    return padded