def batch_iterable(batch_size, iterable):
    """Return batches to be processes from the given iterable."""
    batch = []
    count = 0
    for element in iterable:
        count += 1
        batch.append(element)
        if count == batch_size:
            yield batch.copy()
            batch.clear()
            count = 0
    yield batch
