class_docstr: CSV file logger. CSV headers are time, step, and names passed to `log`.
  
  Args:
      path (str): path to write logs to
      steps_before_flushing: (int, optional): Number of steps to buffer in logger before flushing
      log_all_ranks: (bool, optional): Log all ranks if true, else log only on rank 0.
      async_write: (bool, optional): Whether to write asynchronously or not. Defaults to False.
class_docstr_tok: ["CSV","file","logger",".","CSV","headers","are","time",",","step",",","and","names","passed","to","`","log","`",".","Args",":","path","(","str",")",":","path","to","write","logs","to","steps_before_flushing",":","(","int",",","optional",")",":","Number","of","steps","to","buffer","in","logger","before","flushing","log_all_ranks",":","(","bool",",","optional",")",":","Log","all","ranks","if","true",",","else","log","only","on","rank","0.","async_write",":","(","bool",",","optional",")",":","Whether","to","write","asynchronously","or","not",".","Defaults","to","False","."]
code: def flush(self) -> None:
      if self._rank == 0 or self._log_all_ranks:
          buffer = self._log_buffer
          if not buffer:
              logger.debug("No logs to write.")
              return
  
          if self._thread:
              # ensure previous thread is completed before next write
              self._thread.join()
  
          data_list = list(buffer.values())
          if not self._async_write:
              _write_csv(self.path, data_list)
              return
  
          self._thread = Thread(
              target=_write_csv, args=(self.path, data_list)
          )
          self._thread.start()
  
file_path: tnt/torchtnt/utils/loggers/csv.py
imports: import csv
  import logging
  from threading import Thread
  from typing import Dict, List, Optional
  from fsspec import open
  from torchtnt.utils.loggers.file import FileLogger
  from torchtnt.utils.loggers.logger import MetricLogger
label_desc: Use image node_id 2 for calling the CSVLogger obj's underlying member method code with example usage: obj.flush() without return types