def _chunks(lst: list, n: int, reverse: bool) ->list:
    """
    Chunk list into length 'n' sublists.

    Parameters
    ----------
    lst
        list to chunk
    n
        length of chunks
    reverse
        reverse the order of chunks
    """
    rng = range(0, len(lst), n)
    if reverse:
        rng = rng[::-1]
    for i in rng:
        yield lst[i:i + n]
