def get_valid_kernel_sizes(kernel):
    """
    Provides the sizes along the dimensions of the kernel,
    outermost to innermost for a valid kernel

    Parameters
    ----------
    kernel: nested list
    a valid N-dimensional kernel for computation
    
    Returns
    -------
    sizes: list
    1-D list of sizes, dimensions are ordered outermost to innermost
    """

    def kernel_dim_recur(subkernel):
        if isinstance(subkernel, list):
            if len(subkernel) > 0:
                return [len(subkernel)] + kernel_dim_recur(subkernel[0])
            else:
                return [0]

        else:
            return []
    return kernel_dim_recur(kernel)