code: def on_iteration_end(self, iter_cnt, data):
      loss_train = 0
      if data.get("y_train_predicted") is not None:
          loss_train = self.metric(
              data.get("y_train_true"), data.get("y_train_predicted")
          )
      loss_validation = self.metric(
          data.get("y_validation_true"),
          data.get("y_validation_predicted"),
      )
  
      for loss in [loss_train, loss_validation]:
          if np.isnan(loss) or np.isinf(loss) or np.isneginf(loss):
              self.learner.stop_training = True
              log.info("Terminating learning, invalid loss value")
  
imports: import logging
  import numpy
  from supervised.callbacks.callback import Callback
label_desc: Use image node_id 2 for calling the TerminateOnNan obj's underlying member method code with example usage: obj.on_iteration_end(iter_cnt, data) without return types