def get_spatial_gradient_kernel3d(
    mode: str, order: int, device: Optional[Device] = None, dtype: Optional[Dtype] = None
) -> Tensor:
    r"""Return kernel for 1st or 2nd order scale pyramid gradients.

    Uses one of the following operators: sobel, diff.
    """
    KORNIA_CHECK(mode.lower() in {"sobel", "diff"}, f"Mode should be `sobel` or `diff`. Got {mode}")
    KORNIA_CHECK(order in {1, 2}, f"Order should be 1 or 2. Got {order}")

    if mode == "diff" and order == 1:
        kernel = get_diff_kernel3d(device=device, dtype=dtype)
    elif mode == "diff" and order == 2:
        kernel = get_diff_kernel3d_2nd_order(device=device, dtype=dtype)
    else:
        raise NotImplementedError(f"Not implemented 3d gradient kernel for order {order} on mode {mode}")

    return kernel
Return kernel for 1st or 2nd order scale pyramid gradients.

    Uses one of the following operators: sobel, diff.
    
kornia/filters/kernels.py