code: def test_on_nan_during_train_print_error(self):
      terminate_on_nan = TerminateOnNaN()
      terminate_on_nan.set_model(self.model)
  
      a_batch_number = 1
      a_loss_logs_with_nan = {"loss": np.array([np.nan])}
      self._capture_output()
      terminate_on_nan.on_train_batch_end(
          batch_number=a_batch_number, logs=a_loss_logs_with_nan
      )
  
      self.assertStdoutContains(
          [
              f"Batch {a_batch_number:d}: Invalid loss, terminating training"
          ]
      )
  
file_path: poutyne/tests/framework/callbacks/test_terminate_on_nan.py
imports: import numpy
  import torch
  import torch.nn
  from poutyne import Model, TerminateOnNaN
  from tests.framework.base import CaptureOutputBase
  from tests.framework.tools import some_data_generator
label_desc: Use image node_id 3 for calling the TerminateOnNaNTest obj's underlying member method code with example usage: obj.test_on_nan_during_train_print_error() without return types