class_docstr: Callback that terminates training when a NaN loss is encountered.
code: def on_batch_end(self, batch, logs=None):
      logs = logs or {}
      loss = logs.get("loss")
      if loss is not None:
          if np.isnan(loss) or np.isinf(loss):
              io_utils.print_msg(
                  f"Batch {batch}: Invalid loss, terminating training"
              )
              self.model.stop_training = True
  
imports: import numpy
  from keras.api_export import keras_export
  from keras.callbacks.callback import Callback
  from keras.utils import io_utils
label_desc: Use image node_id 1 for calling the TerminateOnNaN obj's underlying member method code with example usage: obj.on_batch_end(batch, logs) without return types