class_docstr: Ignite handler to execute the `decollate batch` logic for `engine.state.batch` and `engine.state.output`.
  Typical usage is to set `decollate=False` in the engine and execute some postprocessing logic first
  then decollate the batch, otherwise, engine will decollate batch before the postprocessing.
  
  Args:
      event: expected EVENT to attach the handler, should be "MODEL_COMPLETED" or "ITERATION_COMPLETED".
          default to "MODEL_COMPLETED".
      detach: whether to detach the tensors. scalars tensors will be detached into number types
          instead of torch tensors.
      decollate_batch: whether to decollate `engine.state.batch` of ignite engine.
      batch_keys: if `decollate_batch=True`, specify the keys of the corresponding items to decollate
          in `engine.state.batch`, note that it will delete other keys not specified. if None,
          will decollate all the keys. it replicates the scalar values to every item of the decollated list.
      decollate_output: whether to decollate `engine.state.output` of ignite engine.
      output_keys: if `decollate_output=True`, specify the keys of the corresponding items to decollate
          in `engine.state.output`, note that it will delete other keys not specified. if None,
          will decollate all the keys. it replicates the scalar values to every item of the decollated list.
      allow_missing_keys: don't raise exception if key is missing.
docstr: Args:
      engine: Ignite Engine, it can be a trainer, validator or evaluator.
docstr_tok: ["Args",":","engine",":","Ignite","Engine",",","it","can","be","a","trainer",",","validator","or","evaluator","."]
code: def attach(self, engine: Engine) -> None:
      """
      Args:
          engine: Ignite Engine, it can be a trainer, validator or evaluator.
      """
      if self.event == "MODEL_COMPLETED":
          engine.add_event_handler(
              IterationEvents.MODEL_COMPLETED, self
          )
      else:
          engine.add_event_handler(Events.ITERATION_COMPLETED, self)
  
file_path: MONAI/monai/handlers/decollate_batch.py
imports: from __future__ import annotations
  from typing import TYPE_CHECKING
  from monai.config import IgniteInfo, KeysCollection
  from monai.engines.utils import IterationEvents
  from monai.transforms import Decollated
  from monai.utils import min_version, optional_import
label_desc: Use image node_id 2 for calling the DecollateBatch obj's underlying member method code with example usage: obj.attach(engine) without return types