Is there any way to dump the whole model's backward pseudo python code?

The overall progress of my model is:

data = model(input)
grad = torch.autograd.grad(data, input)
output grad

The gradient with respect to the input data is the output of the python code. I plan to rewrite the whole model with pure C, but I can not get the straightforward backward code.

Is there any way to dump the whole model’s backward pseudo python code?

I’m not aware of a way to export the backward Python code in PyTorch for a full model.