from typing import List
import itertools


def chunk(nb_item: int, nb_chunks: int, start_offset=0) -> List[slice]:
    """
    Return `nb_chunks` slices of approximatively `nb_item / nb_chunks` each.

    Parameters
    ----------
    nb_item : int
        Total number of items

    nb_chunks : int
        Number of chunks to return

    start_offset : int
        Shift start of slice by this amount

    Returns
    -------
    A list of slices

    Examples
    --------
    >>> chunks = chunk(103, 4)
    >>> chunks
    [slice(0, 26, None), slice(26, 52, None), slice(52, 78, None), slice(78, 103, None)]
    """
    if nb_item <= nb_chunks:
        return [slice(max(0, idx - start_offset), idx + 1) for idx in range(nb_item)]

    quotient = nb_item // nb_chunks
    remainder = nb_item % nb_chunks

    quotients = [quotient] * nb_chunks
    remainders = [1] * remainder + [0] * (nb_chunks - remainder)

    nb_elems_per_chunk = [
        quotient + remainder for quotient, remainder in zip(quotients, remainders)
    ]

    accumulated = list(itertools.accumulate(nb_elems_per_chunk))
    shifted_accumulated = accumulated.copy()
    shifted_accumulated.insert(0, 0)
    shifted_accumulated.pop()

    return [
        slice(max(0, begin - start_offset), end)
        for begin, end in zip(shifted_accumulated, accumulated)
    ]