class_docstr: Event handler triggered on completing every iteration to save the classification predictions as CSV file.
  If running in distributed data parallel, only saves CSV file in the specified rank.
class_docstr_tok: ["Event","handler","triggered","on","completing","every","iteration","to","save","the","classification","predictions","as","CSV","file",".","If","running","in","distributed","data","parallel",",","only","saves","CSV","file","in","the","specified","rank","."]
docstr: All gather classification results from ranks and save to CSV file.
  
  Args:
      _engine: Ignite Engine, unused argument.
docstr_tok: ["All","gather","classification","results","from","ranks","and","save","to","CSV","file",".","Args",":","_engine",":","Ignite","Engine",",","unused","argument","."]
code: def _finalize(self, _engine: Engine) -> None:
      """
      All gather classification results from ranks and save to CSV file.
  
      Args:
          _engine: Ignite Engine, unused argument.
      """
      ws = idist.get_world_size()
      if self.save_rank >= ws:
          raise ValueError(
              "target save rank is greater than the distributed group size."
          )
  
      outputs = torch.stack(self._outputs, dim=0)
      filenames = self._filenames
      if ws > 1:
          outputs = evenly_divisible_all_gather(outputs, concat=True)
          filenames = string_list_all_gather(filenames)
  
      if len(filenames) == 0:
          meta_dict = None
      else:
          if len(filenames) != len(outputs):
              warnings.warn(
                  f"filenames length: {len(filenames)} doesn't match outputs length: {len(outputs)}."
              )
          meta_dict = {Key.FILENAME_OR_OBJ: filenames}
  
      # save to CSV file only in the expected rank
      if idist.get_rank() == self.save_rank:
          saver = self.saver or CSVSaver(
              output_dir=self.output_dir,
              filename=self.filename,
              overwrite=self.overwrite,
              delimiter=self.delimiter,
          )
          saver.save_batch(outputs, meta_dict)
          saver.finalize()
  
file_path: MONAI/monai/handlers/classification_saver.py
imports: from __future__ import annotations
  import logging
  import warnings
  from collections.abc import Callable
  from typing import TYPE_CHECKING
  import torch
  from monai.config import IgniteInfo
  from monai.data import CSVSaver, decollate_batch
  from monai.utils import ImageMetaKey
  from monai.utils import evenly_divisible_all_gather, min_version, optional_import, string_list_all_gather
label_desc: Use image node_id 5 for calling the ClassificationSaver obj's underlying member method code with example usage: obj._finalize(_engine) without return types