with_detect_anomaly: Context-manager that enable anomaly detection for the autograd engine.
Description
This does two things:
Usage
with_detect_anomaly(code)
Arguments
code
Code that will be executed in the detect anomaly context.
Warning
This mode should be enabled only for debugging as the different tests
will slow down your program execution.
Details
Running the forward pass with detection enabled will allow the backward
pass to print the traceback of the forward operation that created the failing
backward function.
Any backward computation that generate "nan" value will raise an error.