class_docstr: Save the data in a dictionary format cache, and write to a CSV file finally.
  Typically, the data can be classification predictions, call `save` for single data
  or call `save_batch` to save a batch of data together, and call `finalize` to write
  the cached data into CSV file. If no metadata provided, use index from 0 to save data.
  Note that this saver can't support multi-processing because it reads / writes single
  CSV file and can't guarantee the data order in multi-processing situation.
docstr: Writes the cached dict to a csv
docstr_tok: ["Writes","the","cached","dict","to","a","csv"]
code: def finalize(self) -> None:
      """
      Writes the cached dict to a csv
  
      """
      if not self.output_dir.exists():
          self.output_dir.mkdir(parents=True, exist_ok=True)
      with open(self._filepath, "a") as f:
          for k, v in self._cache_dict.items():
              f.write(k)
              for result in v.flatten():
                  f.write(self.delimiter + str(result))
              f.write("\n")
      # clear cache content after writing
      self.reset_cache()
  
file_path: MONAI/monai/data/csv_saver.py
imports: from __future__ import annotations
  import os
  import warnings
  from collections import OrderedDict
  from pathlib import Path
  import numpy
  import torch
  from monai.config.type_definitions import PathLike
  from monai.utils import ImageMetaKey
label_desc: Use image node_id 2 for calling the CSVSaver obj's underlying member method code with example usage: obj.finalize() without return types