class_docstr: Runs a given ``process_function`` over each batch of a dataset, emitting events as it goes.
  
  Args:
      process_function: A function receiving a handle to the engine and the current batch
          in each iteration, and returns data to be stored in the engine's state.
  
  Attributes:
      state: object that is used to pass internal and user-defined state between event handlers.
          It is created with the engine and its attributes (e.g. ``state.iteration``, ``state.epoch`` etc) are reset
          on every :meth:`~ignite.engine.engine.Engine.run`.
      last_event_name: last event name triggered by the engine.
  
  Note:
      :class:`~ignite.engine.engine.Engine` implementation has changed in v0.4.10 with "interrupt/resume" feature.
      Engine may behave differently on certain corner cases compared to the one from v0.4.9 and before.
      In such case, you can set ``Engine.interrupt_resume_enabled = False`` to restore previous behaviour.
  
  Examples:
      Create a basic trainer
  
      .. code-block:: python
  
          model = ...
          model = model.cuda()
          optimized = ...
          criterion = ...
  
          def train_step(engine, batch):
              model.train()
              inputs, targets = batch[0].cuda(), batch[1].cuda()
              optimizer.zero_grad()
              outputs = model(inputs)
              loss = criterion(outputs, targets)
              loss.backward()
              optimizer.step()
              return loss.item()
  
          trainer = Engine(update_model)
  
          @trainer.on(Events.ITERATION_COMPLETED(every=100))
          def log_training(engine):
              batch_loss = engine.state.output
              lr = optimizer.param_groups[0]['lr']
              e = engine.state.epoch
              n = engine.state.max_epochs
              i = engine.state.iteration
              print(f"Epoch {e}/{n} : {i} - batch loss: {batch_loss}, lr: {lr}")
  
          trainer.run(data_loader, max_epochs=5)
  
          > Epoch 1/5 : 100 - batch loss: 0.10874069479016124, lr: 0.01
          > ...
          > Epoch 2/5 : 1700 - batch loss: 0.4217900575859437, lr: 0.01
  
      Create a basic evaluator to compute metrics
  
      .. code-block:: python
  
          from ignite.metrics import Accuracy
  
          def predict_on_batch(engine, batch)
              model.eval()
              with torch.no_grad():
                  x, y = prepare_batch(batch, device=device, non_blocking=non_blocking)
                  y_pred = model(x)
  
              return y_pred, y
  
          evaluator = Engine(predict_on_batch)
          Accuracy().attach(evaluator, "val_acc")
          evaluator.run(val_dataloader)
  
      Compute image mean/std on training dataset
  
      .. code-block:: python
  
          from ignite.metrics import Average
  
          def compute_mean_std(engine, batch):
              b, c, *_ = batch['image'].shape
              data = batch['image'].reshape(b, c, -1).to(dtype=torch.float64)
              mean = torch.mean(data, dim=-1).sum(dim=0)
              mean2 = torch.mean(data ** 2, dim=-1).sum(dim=0)
              return {"mean": mean, "mean^2": mean2}
  
          compute_engine = Engine(compute_mean_std)
          img_mean = Average(output_transform=lambda output: output['mean'])
          img_mean.attach(compute_engine, 'mean')
          img_mean2 = Average(output_transform=lambda output: output['mean^2'])
          img_mean2.attach(compute_engine, 'mean2')
          state = compute_engine.run(train_loader)
          state.metrics['std'] = torch.sqrt(state.metrics['mean2'] - state.metrics['mean'] ** 2)
          mean = state.metrics['mean'].tolist()
          std = state.metrics['std'].tolist()
  
      Resume engine's run from a state. User can load a `state_dict` and run engine starting from loaded state :
  
      .. code-block:: python
  
          # Restore from an epoch
          state_dict = {"epoch": 3, "max_epochs": 100, "epoch_length": len(data_loader)}
          # or an iteration
          # state_dict = {"iteration": 500, "max_epochs": 100, "epoch_length": len(data_loader)}
  
          trainer = Engine(...)
          trainer.load_state_dict(state_dict)
          trainer.run(data)
docstr: Returns a dictionary containing engine's state: "epoch_length", "max_epochs" and "iteration" and
  other state values defined by `engine.state_dict_user_keys`
  
  .. code-block:: python
  
      engine = Engine(...)
      engine.state_dict_user_keys.append("alpha")
      engine.state_dict_user_keys.append("beta")
      ...
  
      @engine.on(Events.STARTED)
      def init_user_value(_):
           engine.state.alpha = 0.1
           engine.state.beta = 1.0
  
      @engine.on(Events.COMPLETED)
      def save_engine(_):
          state_dict = engine.state_dict()
          assert "alpha" in state_dict and "beta" in state_dict
          torch.save(state_dict, "/tmp/engine.pt")
  
  Returns:
      OrderedDict:
          a dictionary containing engine's state
docstr_tok: ["Returns","a","dictionary","containing","engine","'s","state",":","``","epoch_length","''",",","``","max_epochs","''","and","``","iteration","''","and","other","state","values","defined","by","`","engine.state_dict_user_keys","`","..","code-block",":",":","python","engine","=","Engine","(","...",")","engine.state_dict_user_keys.append","(","``","alpha","''",")","engine.state_dict_user_keys.append","(","``","beta","''",")","...","@","engine.on","(","Events.STARTED",")","def","init_user_value","(","_",")",":","engine.state.alpha","=","0.1","engine.state.beta","=","1.0","@","engine.on","(","Events.COMPLETED",")","def","save_engine","(","_",")",":","state_dict","=","engine.state_dict","(",")","assert","``","alpha","''","in","state_dict","and","``","beta","''","in","state_dict","torch.save","(","state_dict",",","``","\/tmp\/engine.pt","''",")","Returns",":","OrderedDict",":","a","dictionary","containing","engine","'s","state"]
code: def state_dict(self) -> OrderedDict:
      """Returns a dictionary containing engine's state: "epoch_length", "max_epochs" and "iteration" and
      other state values defined by `engine.state_dict_user_keys`
  
      .. code-block:: python
  
          engine = Engine(...)
          engine.state_dict_user_keys.append("alpha")
          engine.state_dict_user_keys.append("beta")
          ...
  
          @engine.on(Events.STARTED)
          def init_user_value(_):
               engine.state.alpha = 0.1
               engine.state.beta = 1.0
  
          @engine.on(Events.COMPLETED)
          def save_engine(_):
              state_dict = engine.state_dict()
              assert "alpha" in state_dict and "beta" in state_dict
              torch.save(state_dict, "/tmp/engine.pt")
  
      Returns:
          OrderedDict:
              a dictionary containing engine's state
  
      """
      keys: Tuple[str, ...] = self._state_dict_all_req_keys + (
          self._state_dict_one_of_opt_keys[0],
      )
      keys += tuple(self._state_dict_user_keys)
      return OrderedDict([(k, getattr(self.state, k)) for k in keys])
  
imports: import functools
  import logging
  import math
  import time
  import warnings
  import weakref
  from collections import defaultdict, OrderedDict
  from collections.abc import Mapping
  from typing import Any, Callable, Dict, Generator, Iterable, Iterator, List, Optional, Tuple, Union
  from torch.utils.data import DataLoader
  from ignite.base import Serializable
  from ignite.engine.events import CallableEventWithFilter, EventEnum, Events, EventsList, RemovableEventHandle, State
  from ignite.engine.utils import _check_signature, _to_hours_mins_secs
label_desc: Use image node_id 17 for calling the Engine obj's underlying member method code with example usage: obj.state_dict() and returns: OrderedDict