How do I pass a forward value to a backward function

If there are two autograds function f and g and backward() function involving the composite (fog) is called, how can I make the backward(ctx, *grad_outputs) of f dependent on the forward value of g (not just its gradients)?

Hmm not sure what you mean by this. Could you talk a bit more about your example? Are you trying to produce higher-order gradients?