So error you hit is in the backward. The first thing I would recommend to do for this is use the (very slow) ẁith torch.anomaly_detection() mode as it will give you the backtrace of the backward.
Best regards
Thomas