class_docstr: A `Callback` that terminates training if loss is NaN.
class_docstr_tok: ["A","`","Callback","`","that","terminates","training","if","loss","is","NaN","."]
docstr: Test if `last_loss` is NaN and interrupts training.
docstr_tok: ["Test","if","`","last_loss","`","is","NaN","and","interrupts","training","."]
code: def after_batch(self):
      "Test if `last_loss` is NaN and interrupts training."
      if torch.isinf(self.loss) or torch.isnan(self.loss):
          raise CancelFitException
  
imports: from __future__ import annotations
  from ..basics import *
  from .progress import *
  from .fp16 import MixedPrecision
label_desc: Use image node_id 1 for calling the TerminateOnNaNCallback obj's underlying member method code with example usage: obj.after_batch() without return types