There isn’t a way to call ctc’s backward independently of the forward (and not in general, either).
This limits you to not manipulating the inputs to the forward that are passed to the grad.
You can wrap the call to ctc loss into a custom autograd function (detaching + enable_grad + storing the result as intermediate and returning a detached) and then call that the backward on that during the backward of the autograd function.
Personally, I’d think that it’d be cool to expose all backwards in a standard way (and also get rid of sticking them in the Functions.cpp template), but that never gained traction with anyone else.
Best regards
Thomas