code: def test_state_dict_with_user_keys():
      engine = Engine(lambda e, b: 1)
      engine.state_dict_user_keys.append("alpha")
      engine.state_dict_user_keys.append("beta")
  
      def _test(state):
          engine.state = state
          sd = engine.state_dict()
          assert isinstance(sd, Mapping) and len(sd) == len(
              engine._state_dict_all_req_keys
          ) + 1 + len(engine.state_dict_user_keys)
          assert sd["iteration"] == engine.state.iteration
          assert sd["epoch_length"] == engine.state.epoch_length
          assert sd["max_epochs"] == engine.state.max_epochs
          assert sd["alpha"] == engine.state.alpha
          assert sd["beta"] == engine.state.beta
  
      _test(
          State(
              iteration=500,
              epoch_length=1000,
              max_epochs=100,
              alpha=0.01,
              beta="Good",
          )
      )
  
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 2 for calling a global function with example usage: test_state_dict_with_user_keys() without return types