class_docstr: Workflow defines the core work process inheriting from Ignite engine.
  All trainer, validator and evaluator share this same workflow as base class,
  because they all can be treated as same Ignite engine loops.
  It initializes all the sharable data in Ignite engine.state.
  And attach additional processing logics to Ignite engine based on Event-Handler mechanism.
  
  Users should consider inheriting from `trainer` or `evaluator` to develop more trainers or evaluators.
  
  Args:
      device: an object representing the device on which to run.
      max_epochs: the total epoch number for engine to run, validator and evaluator have only 1 epoch.
      data_loader: Ignite engine use data_loader to run, must be Iterable or torch.DataLoader.
      epoch_length: number of iterations for one epoch, default to `len(data_loader)`.
      non_blocking: if True and this copy is between CPU and GPU, the copy may occur asynchronously
          with respect to the host. For other cases, this argument has no effect.
      prepare_batch: function to parse expected data (usually `image`, `label` and other network args)
          from `engine.state.batch` for every iteration, for more details please refer to:
          https://pytorch.org/ignite/generated/ignite.engine.create_supervised_trainer.html.
      iteration_update: the callable function for every iteration, expect to accept `engine`
          and `engine.state.batch` as inputs, return data will be stored in `engine.state.output`.
          if not provided, use `self._iteration()` instead. for more details please refer to:
          https://pytorch.org/ignite/generated/ignite.engine.engine.Engine.html.
      postprocessing: execute additional transformation for the model output data.
          Typically, several Tensor based transforms composed by `Compose`.
      key_metric: compute metric when every iteration completed, and save average value to
          engine.state.metrics when epoch completed. key_metric is the main metric to compare and save the
          checkpoint into files.
      additional_metrics: more Ignite metrics that also attach to Ignite Engine.
      metric_cmp_fn: function to compare current key metric with previous best key metric value,
          it must accept 2 args (current_metric, previous_best) and return a bool result: if `True`, will update
          `best_metric` and `best_metric_epoch` with current metric and epoch, default to `greater than`.
      handlers: every handler is a set of Ignite Event-Handlers, must have `attach` function, like:
          CheckpointHandler, StatsHandler, etc.
      amp: whether to enable auto-mixed-precision training or inference, default is False.
      event_names: additional custom ignite events that will register to the engine.
          new events can be a list of str or `ignite.engine.events.EventEnum`.
      event_to_attr: a dictionary to map an event to a state attribute, then add to `engine.state`.
          for more details, check: https://pytorch.org/ignite/generated/ignite.engine.engine.Engine.html
          #ignite.engine.engine.Engine.register_events.
      decollate: whether to decollate the batch-first data to a list of data after model computation,
          recommend `decollate=True` when `postprocessing` uses components from `monai.transforms`.
          default to `True`.
      to_kwargs: dict of other args for `prepare_batch` API when converting the input data, except for
          `device`, `non_blocking`.
      amp_kwargs: dict of the args for `torch.cuda.amp.autocast()` API, for more details:
          https://pytorch.org/docs/stable/amp.html#torch.cuda.amp.autocast.
  
  Raises:
      TypeError: When ``data_loader`` is not a ``torch.utils.data.DataLoader``.
      TypeError: When ``key_metric`` is not a ``Optional[dict]``.
      TypeError: When ``additional_metrics`` is not a ``Optional[dict]``.
docstr: Register the postprocessing logic to the engine, will execute them as a chain when iteration completed.
docstr_tok: ["Register","the","postprocessing","logic","to","the","engine",",","will","execute","them","as","a","chain","when","iteration","completed","."]
code: def _register_postprocessing(self, posttrans: Callable) -> None:
      """
      Register the postprocessing logic to the engine, will execute them as a chain when iteration completed.
  
      """
  
      @self.on(IterationEvents.MODEL_COMPLETED)
      def _run_postprocessing(engine: Engine) -> None:
          if not isinstance(engine.state.batch, list) or not isinstance(
              engine.state.output, list
          ):
              (
                  engine.state.batch,
                  engine.state.output,
              ) = engine_apply_transform(
                  batch=engine.state.batch,
                  output=engine.state.output,
                  transform=posttrans,
              )
          else:
              for i, (b, o) in enumerate(
                  zip(engine.state.batch, engine.state.output)
              ):
                  (
                      engine.state.batch[i],
                      engine.state.output[i],
                  ) = engine_apply_transform(b, o, posttrans)
  
imports: from __future__ import annotations
  import warnings
  from collections.abc import Callable, Iterable, Sequence
  from typing import TYPE_CHECKING, Any
  import torch
  import torch.distributed
  from torch.utils.data import DataLoader
  from torch.utils.data.distributed import DistributedSampler
  from monai.config import IgniteInfo
  from monai.engines.utils import IterationEvents, default_metric_cmp_fn, default_prepare_batch
  from monai.transforms import Decollated
  from monai.utils import ensure_tuple, is_scalar, min_version, optional_import
  from .utils import engine_apply_transform
label_desc: Use image node_id 3 for calling the Workflow obj's underlying member method code with example usage: obj._register_postprocessing(posttrans) without return types