def batched()

in sparse_autoencoder/explanations.py [0:0]


def batched(iterable, bs):
    batch = []
    it = iter(iterable)
    while True:
        batch = []
        try:
            for _ in range(bs):
                batch.append(next(it))
            yield batch
        except StopIteration:
            if len(batch) > 0:
                yield batch
            return