import math


def gen_split_slices(total_len, part_len=None, n_parts=None):
    """Generate slices to split a sequence.

    Returns a list of slices to split a sequence into smaller pieces.

    Args:
        total_len (int): Length of the full sequence.
        part_len (int, optional): Length of each piece, may be None if
            n_parts is specified.
        n_parts (int, optional): Number of pieces, ignored if part_len
            is specified.

    Returns:
        (list of slice) Slices to split the sequence.
    """

    if part_len is None:
        if n_parts is None:
            raise ValueError('must specify either part_len or n_parts')

    else:
        n_parts = math.ceil(total_len / part_len)

    return [slice(i * total_len // n_parts, (i+1) * total_len // n_parts)
            for i in range(n_parts)]