You should use create_graph=True when you want higher order derivatives (like hessian or gradient penalty) otherwise you don’t need it.
In the custom Function, the forward always run in a no_grad mode. So you don’t need to check the requires_grad field in there. The history will properly be attached to the Tensor you return on exit.
For the backward, it run with grad mode enabled only if you set create_graph=True. If you don’t, then it will also not run in grad mode and you can ignore the requires_grad fields in there.