code: def test_load_state_dict():
      engine = Engine(lambda e, b: 1)
  
      def _test(sd):
          engine.load_state_dict(sd)
          if "iteration" in sd:
              assert sd["iteration"] == engine.state.iteration
          elif "epoch" in sd:
              assert sd["epoch"] == engine.state.epoch
          assert sd["epoch_length"] == engine.state.epoch_length
          assert sd["max_epochs"] == engine.state.max_epochs
  
      _test({"max_epochs": 100, "epoch_length": 120, "iteration": 123})
      _test({"max_epochs": 100, "epoch_length": 120, "epoch": 5})
  
file_path: ignite/tests/ignite/engine/test_engine_state_dict.py
imports: from collections.abc import Mapping
  import pytest
  import torch
  from ignite.engine import Engine, Events, State
  from tests.ignite.engine import BatchChecker, EpochCounter, IterationCounter
label_desc: Use image node_id 5 for calling a global function with example usage: test_load_state_dict() without return types