code: def test_state_custom_attrs_init():
      def _test(with_load_state_dict=False):
          engine = Engine(lambda e, b: None)
          engine.state.alpha = 0.0
          engine.state.beta = 1.0
  
          if with_load_state_dict:
              engine.load_state_dict(
                  {"iteration": 3, "max_epochs": 5, "epoch_length": 5}
              )
  
          @engine.on(
              Events.STARTED
              | Events.EPOCH_STARTED
              | Events.EPOCH_COMPLETED
              | Events.COMPLETED
          )
          def check_custom_attr():
              assert (
                  hasattr(engine.state, "alpha")
                  and engine.state.alpha == 0.0
              )
              assert (
                  hasattr(engine.state, "beta")
                  and engine.state.beta == 1.0
              )
  
          engine.run([0, 1, 2, 3, 4], max_epochs=5)
  
      _test()
      _test(with_load_state_dict=True)
  
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 13 for calling a global function with example usage: test_state_custom_attrs_init() without return types