Очень внимательно! Не дает обходить дважды

    :param iterable:
    :param count_items_in_chunk:
    :return:

def chunks_generator(iterable, count_items_in_chunk):
    """
    Очень внимательно! Не дает обходить дважды

    :param iterable:
    :param count_items_in_chunk:
    :return:
    """
    iterator = iter(iterable)
    for first in iterator:  # stops when iterator is depleted
        def chunk():  # construct generator for next chunk
            yield first  # yield element from for loop
            for more in islice(iterator, count_items_in_chunk - 1):
                yield more  # yield more elements from the iterator

        yield chunk()