code: def test_one_save_one_load(self):
      net1 = torch.nn.PReLU()
      data1 = net1.state_dict()
      data1["weight"] = torch.tensor([0.1])
      net1.load_state_dict(data1)
      net2 = torch.nn.PReLU()
      data2 = net2.state_dict()
      data2["weight"] = torch.tensor([0.2])
      net2.load_state_dict(data2)
      with tempfile.TemporaryDirectory() as tempdir:
          engine1 = Engine(lambda e, b: None)
          CheckpointSaver(
              save_dir=tempdir,
              save_dict={"net": net1, "eng": engine1},
              save_final=True,
          ).attach(engine1)
          engine1.run([0] * 8, max_epochs=5)
          path = tempdir + "/checkpoint_final_iteration=40.pt"
          engine2 = Engine(lambda e, b: None)
          CheckpointLoader(
              load_path=path,
              load_dict={"net": net2, "eng": engine2},
              strict=True,
          ).attach(engine2)
  
          @engine2.on(Events.STARTED)
          def check_epoch(engine: Engine):
              self.assertEqual(engine.state.epoch, 5)
  
          engine2.run([0] * 8, max_epochs=8)
          assert_allclose(
              net2.state_dict()["weight"], torch.tensor([0.1])
          )
  
          # test bad case with max_epochs smaller than current epoch
          engine3 = Engine(lambda e, b: None)
          CheckpointLoader(
              load_path=path,
              load_dict={"net": net2, "eng": engine3},
              strict=True,
          ).attach(engine3)
  
          try:
              engine3.run([0] * 8, max_epochs=3)
          except ValueError:
              self.assertEqual(engine3.state.epoch, 5)
              self.assertEqual(engine3.state.max_epochs, 5)
  
file_path: MONAI/tests/test_handler_checkpoint_loader.py
imports: from __future__ import annotations
  import tempfile
  import unittest
  import torch
  import torch.optim
  from ignite.engine import Engine, Events
  from monai.handlers import CheckpointLoader, CheckpointSaver
  from tests.utils import assert_allclose
label_desc: Use image node_id 1 for calling the TestHandlerCheckpointLoader obj's underlying member method code with example usage: obj.test_one_save_one_load() without return types