from typing import Sequence
from typing import Iterator


def chunks(elements: Sequence, size, lazy=False) -> Iterator[Sequence] | list[Sequence]:
    """Create successive n-sized chunks from elements."""

    generator_ = (elements[i:i + size] for i in range(0, len(elements), size))
    if lazy:
        return generator_
    else:
        return list(generator_)