def slice_list(in_list, lens):
    """Slice a list into several sub lists by a list of given length.
    Args:
        in_list (list): The list to be sliced.
        lens(int or list): The expected length of each out list.
    Returns:
        list: A list of sliced list.
    """
    if isinstance(lens, int):
        assert len(in_list) % lens == 0
        lens = [lens] * int(len(in_list) / lens)
    if not isinstance(lens, list):
        raise TypeError('"indices" must be an integer or a list of integers')
    elif sum(lens) != len(in_list):
        raise ValueError(
            "sum of lens and list length does not "
            f"match: {sum(lens)} != {len(in_list)}"
        )
    out_list = []
    idx = 0
    for i in range(len(lens)):
        out_list.append(in_list[idx : idx + lens[i]])
        idx += lens[i]
    return out_list