class_docstr: Generic logger callback for dumping experiment data. Can be extended for more utility.
class_docstr_tok: ["Generic","logger","callback","for","dumping","experiment","data",".","Can","be","extended","for","more","utility","."]
code: def on_train_begin(self, logs=None):
      if self.append:
          open_type = "a"
      else:
          open_type = "w"
  
      # if append is True, find whether the file already has header
      num_lines = 0
      if self.append:
          if os.path.exists(self.file):
              with open(self.file) as f:
                  for num_lines, l in enumerate(f):
                      pass
                  # if header exists, DONT append header again
              with open(self.file) as f:
                  self.append_header = not bool(len(f.readline()))
  
      model_idx = num_lines
      REJECT_KEYS = {"has_validation_data"}
      MODEL_NAME = self.save_prefix + str(
          model_idx
      )  # figure out how to get model name
      self.row_dict = OrderedDict({"model": MODEL_NAME})
      self.keys = sorted(logs.keys())
      for k in self.keys:
          if k not in REJECT_KEYS:
              self.row_dict[k] = logs[k]
  
      class CustomDialect(csv.excel):
          delimiter = self.sep
  
      with open(self.file, open_type) as csv_file:
          writer = csv.DictWriter(
              csv_file,
              fieldnames=["model"]
              + [k for k in self.keys if k not in REJECT_KEYS],
              dialect=CustomDialect,
          )
          if self.append_header:
              writer.writeheader()
  
          writer.writerow(self.row_dict)
          csv_file.flush()
  
file_path: pywick/pywick/callbacks/ExperimentLogger.py
imports: import csv
  import os
  import shutil
  from collections import OrderedDict
  from tempfile import NamedTemporaryFile
  from .None import Callback
label_desc: Use image node_id 2 for calling the ExperimentLogger obj's underlying member method code with example usage: obj.on_train_begin(logs) without return types