Consider the following extension of torch.autograd.function:
class MorphingLayer(Function):

    @staticmethod
    def forward(ctx, input, idx):
        
        ctx.save_for_backward(input, idx)
        #implementation of forward pass

    return output1, output2

Assume that the gradient w.r.t. input can be obtained using autograd, but the gradient w.r.t. idx must be implemented manually. How would I achieve that in the implementation of the backward pass, i.e., how can I access input.grad during the backward pass?
@staticmethod
def backward(ctx, gradIdx1,gradIdx2):
    input, idx = ctx.saved_tensors

    #compute gradIdx manually
    gradIdx = (manually computed gradient)

    #obtain gradInput from autograd 
    gradInput = (obtain input.grad)

    return gradInput, gradIdx