code: def _save_stats(self, fd: TextIO, filename: str, stats: Dict):
      olddata = None
      if os.path.exists(filename):
          with open(filename, "r", encoding="utf-8") as oldfile:
              olddata = list(
                  csv.DictReader(oldfile, delimiter=self.separator)
              )
      csvwriter = csv.DictWriter(
          fd, fieldnames=self.fieldnames, delimiter=self.separator
      )
      csvwriter.writeheader()
      if olddata is not None:
          csvwriter.writerows(olddata)
      csvwriter.writerow(stats)
  
imports: import csv
  import os
  from typing import Dict, List, Optional, TextIO, Union
  import torch
  from poutyne.framework.callbacks._utils import atomic_lambda_save
  from poutyne.framework.callbacks.callbacks import Callback
label_desc: Use image node_id 2 for calling the AtomicCSVGradientLogger obj's underlying member method code with example usage: obj._save_stats(fd, filename, stats) without return types