class_docstr: Callback which montiors the given metric and halts training if its value is nan or inf.
  
  Example: ::
  
      >>> import torch.nn
      >>> from torchbearer import Trial
      >>> from torchbearer.callbacks import TerminateOnNaN
  
      # Example Trial which terminates on a NaN, forced by a separate callback. Terminates on the 11th batch since
      the running loss only updates every 10 iterations.
      >>> term = TerminateOnNaN(monitor='running_loss')
      >>> @torchbearer.callbacks.on_criterion
      ... def force_terminate(state):
      ...     if state[torchbearer.BATCH] == 5:
      ...         state[torchbearer.LOSS] = state[torchbearer.LOSS] * torch.Tensor([float('NaN')])
      >>> trial = Trial(None, callbacks=[term, force_terminate], metrics=['loss'], verbose=2).for_steps(30).run(1)
      Invalid running_loss, terminating
  
  Args:
      monitor (str): The name of the metric to monitor
  
  State Requirements:
      - :attr:`torchbearer.state.METRICS`: Metrics should be a dict containing at least the key `monitor`
class_docstr_tok: ["Callback","which","montiors","the","given","metric","and","halts","training","if","its","value","is","nan","or","inf",".","Example",":",":",":",">",">",">","import","torch.nn",">",">",">","from","torchbearer","import","Trial",">",">",">","from","torchbearer.callbacks","import","TerminateOnNaN","#","Example","Trial","which","terminates","on","a","NaN",",","forced","by","a","separate","callback",".","Terminates","on","the","11th","batch","since","the","running","loss","only","updates","every","10","iterations",".",">",">",">","term","=","TerminateOnNaN","(","monitor='running_loss","'",")",">",">",">","@","torchbearer.callbacks.on_criterion","...","def","force_terminate","(","state",")",":","...","if","state","[","torchbearer.BATCH","]","==","5",":","...","state","[","torchbearer.LOSS","]","=","state","[","torchbearer.LOSS","]","*","torch.Tensor","(","[","float","(","'NaN","'",")","]",")",">",">",">","trial","=","Trial","(","None",",","callbacks=","[","term",",","force_terminate","]",",","metrics=","[","'loss","'","]",",","verbose=2",")",".for_steps","(","30",")",".run","(","1",")","Invalid","running_loss",",","terminating","Args",":","monitor","(","str",")",":","The","name","of","the","metric","to","monitor","State","Requirements",":","-",":","attr",":","`","torchbearer.state.METRICS","`",":","Metrics","should","be","a","dict","containing","at","least","the","key","`","monitor","`"]
code: def on_step_validation(self, state):
      self._check(state)
  
file_path: torchbearer/torchbearer/callbacks/terminate_on_nan.py
imports: from __future__ import print_function
  import torchbearer
  from torchbearer.callbacks import Callback
  from torchbearer.bases import get_metric
  import math
label_desc: Use image node_id 5 for calling the TerminateOnNaN obj's underlying member method code with example usage: obj.on_step_validation(state) without return types