code: def iteration_listener(self, sender, **msg):
      msg = msg["iter_msg"]
      self.assertRegexpMatches(
          msg.to_console_string(), ".*total_loss.*"
      )
      if msg.current_iter > 1:
          self.assertTrue(isinstance(sender.performance_history, list))
          self.assertTrue(
              len(sender.performance_history) <= sender.patience
          )
          self.assertTrue(
              all(
                  [
                      isinstance(p, np.float32)
                      for p in sender.performance_history
                  ]
              )
          )
  
file_path: NiftyNet/tests/handler_performance_test.py
imports: from __future__ import absolute_import, print_function
  import tensorflow
  import numpy
  from tests.application_driver_test import get_initialised_driver
  from niftynet.engine.application_iteration import IterationMessage
  from niftynet.engine.signal import SESS_STARTED, ITER_FINISHED, VALID
  from tests.niftynet_testcase import NiftyNetTestCase
label_desc: Use image node_id 2 for calling the PerformanceLoggerTest obj's underlying member method code with example usage: obj.iteration_listener(sender) without return types