Thanks for the code!
It looks like the error is thrown in the backward call, so we could probably just raise the error using some dummy input and target data without creating the real dataset.
Could you post the shapes and types of data and target?