code: def on_train_begin(self, logs: Dict):
      super().on_train_begin(logs)
      fieldnames = ["epoch", "batch"] + self.stats_names
      open_flag = "a" if self.append else "w"
  
      self.csvfiles = {}
      self.writers = {}
      for layer in self.layers:
          filename = self.filename.format(layer)
          self.csvfiles[layer] = open(
              filename, open_flag, newline="", encoding="utf-8"
          )
          self.writers[layer] = csv.DictWriter(
              self.csvfiles[layer],
              fieldnames=fieldnames,
              delimiter=self.separator,
          )
          if not self.append:
              self.writers[layer].writeheader()
              self.csvfiles[layer].flush()
  
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 CSVGradientLogger obj's underlying member method code with example usage: obj.on_train_begin(logs) without return types