Debugging torch.onnx.export

I’m trying to export a model via ONNX. The export is failing due to an operator not being supported.

RuntimeError: Exporting the operator __derive_index to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator.

Implementing the missing operator is beyond my means, so I want to rewrite this part of the model.
I’m now trying to figure out which line of my model is causing the issue - the ONNX traceback has no info on this at all. I tried putting print statements in-between as recommended elsewhere, but they all get printed until the forward pass end, and then the error appears.

Is there any way to find the problematic line? I can’t make sense of the operator name itself.

Also tracked here with reference to an open PR.