def batch_iterator(iterator, batch_size):
    """
	Returns lists of tuples of length batch_size.
	"""
    entry = True
    while entry:
        batch = []
        while len(batch) < batch_size:
            try:
                entry = iterator.__next__()
            except StopIteration:
                entry = None
            if entry is None:
                break
            batch.append(entry)
        if batch:
            yield batch
