code: def update_summary(
      epoch,
      train_metrics,
      eval_metrics,
      filename,
      lr=None,
      write_header=False,
      log_wandb=False,
  ):
      rowd = OrderedDict(epoch=epoch)
      rowd.update([("train_" + k, v) for k, v in train_metrics.items()])
      if eval_metrics:
          rowd.update(
              [("eval_" + k, v) for k, v in eval_metrics.items()]
          )
      if lr is not None:
          rowd["lr"] = lr
      if log_wandb:
          wandb.log(rowd)
      with open(filename, mode="a") as cf:
          dw = csv.DictWriter(cf, fieldnames=rowd.keys())
          if write_header:  # first iteration (epoch == 1 can't be used)
              dw.writeheader()
          dw.writerow(rowd)
  
imports: import csv
  import os
  from collections import OrderedDict
label_desc: Use image node_id 2 for calling a global function with example usage: update_summary(epoch, train_metrics, eval_metrics, filename, lr, write_header, log_wandb) without return types