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: Args:
      output_dir: output CSV file directory.
      filename: name of the saved CSV file name.
      overwrite: whether to overwriting existing CSV file content, if True, will clear the file before saving.
          otherwise, will append new content to the CSV file.
      flush: whether to write the cache data to CSV file immediately when `save_batch` and clear the cache.
          default to False.
      delimiter: the delimiter character in the saved file, default to "," as the default output type is `csv`.
          to be consistent with: https://docs.python.org/3/library/csv.html#csv.Dialect.delimiter.
docstr_tok: ["Args",":","output_dir",":","output","CSV","file","directory",".","filename",":","name","of","the","saved","CSV","file","name",".","overwrite",":","whether","to","overwriting","existing","CSV","file","content",",","if","True",",","will","clear","the","file","before","saving",".","otherwise",",","will","append","new","content","to","the","CSV","file",".","flush",":","whether","to","write","the","cache","data","to","CSV","file","immediately","when","`","save_batch","`","and","clear","the","cache",".","default","to","False",".","delimiter",":","the","delimiter","character","in","the","saved","file",",","default","to","``",",","''","as","the","default","output","type","is","`","csv","`",".","to","be","consistent","with",":","https",":","\/\/docs.python.org\/3\/library\/csv.html","#","csv.Dialect.delimiter","."]
code: def __init__(
      self,
      output_dir: PathLike = "./",
      filename: str = "predictions.csv",
      overwrite: bool = True,
      flush: bool = False,
      delimiter: str = ",",
  ) -> None:
      """
      Args:
          output_dir: output CSV file directory.
          filename: name of the saved CSV file name.
          overwrite: whether to overwriting existing CSV file content, if True, will clear the file before saving.
              otherwise, will append new content to the CSV file.
          flush: whether to write the cache data to CSV file immediately when `save_batch` and clear the cache.
              default to False.
          delimiter: the delimiter character in the saved file, default to "," as the default output type is `csv`.
              to be consistent with: https://docs.python.org/3/library/csv.html#csv.Dialect.delimiter.
  
      """
      self.output_dir = Path(output_dir)
      self._cache_dict: OrderedDict = OrderedDict()
      if not (isinstance(filename, str) and filename[-4:] == ".csv"):
          warnings.warn(
              "CSV filename is not a string ends with '.csv'."
          )
      self._filepath = self.output_dir / filename
      if self._filepath.exists() and overwrite:
          os.remove(self._filepath)
  
      self.flush = flush
      self.delimiter = delimiter
      self._data_index = 0
  
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 1 to create a new CSVSaver object  with example: obj = CSVSaver(output_dir, filename, overwrite, flush, delimiter)