def minibatch(items, size=<NUM_LIT:8>):
if isinstance(size, int):<EOL><INDENT>size_ = itertools.repeat(size)<EOL><DEDENT>else:<EOL><INDENT>size_ = size<EOL><DEDENT>items = iter(items)<EOL>while True:<EOL><INDENT>batch_size = next(size_)<EOL>batch = list(itertools.islice(items, int(batch_size)))<EOL>if len(batch) == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>yield list(batch)<EOL><DEDENT>
Iterate over batches of items. `size` may be an iterator,
    so that batch-size can vary on each step.