# set_detect_anomaly Source: https://www.tensorplay.cn/docs/generated/tensorplay.autograd.anomaly_mode.set_detect_anomaly.html ```python class tensorplay.autograd.anomaly_mode.set_detect_anomaly(mode: bool, check_nan: bool = True) ``` Context-manager that sets the anomaly detection for the autograd engine on or off. set_detect_anomaly will enable or disable the autograd anomaly detection based on its argument mode. It can be used as a context-manager or as a function. See detect_anomaly above for details of the anomaly detection behaviour. Parameters: - mode ([bool](https://docs.python.org/3/builtins/functions.html#bool)) – Flag whether to enable anomaly detection (True), or disable (False). - check_nan ([bool](https://docs.python.org/3/builtins/functions.html#bool)) – Flag whether to raise an error when the backward generate β€œnan”