How to calculate gradient of Convolution?

Hello all,

I want to implement my custom convolution Function for custom gradient.
So, I need to calculate original gradient of convolution.
How can I implement below code?

class MyConvolution(Function):
    @staticmethod
    def forward(ctx, x, w):        
        ctx.save_for_backward(x, w)        
        out = nn.functional.conv2d(x, w)

        return out
    
    @staticmethod    
    def backward(ctx, grad_output):

        x, w, = ctx.saved_tensors
                
        return **???, ???**

you may need the function fold