code: def test_exception(self):
      net = torch.nn.PReLU()
  
      # set up engine
      def _train_func(engine, batch):
          raise RuntimeError("test exception.")
  
      engine = Engine(_train_func)
  
      # set up testing handler
      with tempfile.TemporaryDirectory() as tempdir:
          stats_handler = CheckpointSaver(
              tempdir, {"net": net}, save_final=True
          )
          stats_handler.attach(engine)
  
          with self.assertRaises(RuntimeError):
              engine.run(range(3), max_epochs=2)
          self.assertTrue(
              os.path.exists(
                  os.path.join(tempdir, "net_final_iteration=1.pt")
              )
          )
  
file_path: MONAI/tests/test_handler_checkpoint_saver.py
imports: from __future__ import annotations
  import os
  import tempfile
  import unittest
  import torch
  import torch.optim
  from ignite.engine import Engine
  from parameterized import parameterized
  from monai.handlers import CheckpointLoader, CheckpointSaver
label_desc: Use image node_id 2 for calling the TestHandlerCheckpointSaver obj's underlying member method code with example usage: obj.test_exception() without return types