def _ser_batch_ixs(num_samples, batch_size):
    """A generator which yields a list of tuples (offset, size) in serial order.

    :param num_samples: Number of available samples.
    :param batch_size: The size of the batch to fill.
    """
    current_index = 0
    batch, batch_count = [], 0
    while True:
        next_fetch = current_index
        next_fetch_size = min(batch_size - batch_count, num_samples -
            next_fetch)
        batch.append((next_fetch, next_fetch_size))
        batch_count += next_fetch_size
        if batch_count == batch_size:
            yield batch
            batch, batch_count = [], 0
        current_index += next_fetch_size
        if current_index == num_samples:
            current_index = 0
