code: def log_to_file(_state={}, **fields):  # noqa: B006
      """Incrementally write logs.tsv in cwd."""
      if "writer" not in _state:
          path = "logs.tsv"
          writeheader = not os.path.exists(path)
          fieldnames = list(fields.keys())
  
          _state["file"] = open(
              path, "a", buffering=1
          )  # Line buffering.
          _state["writer"] = csv.DictWriter(
              _state["file"], fieldnames, delimiter="\t"
          )
          if writeheader:
              _state["writer"].writeheader()
              print("Writing logs to", path)
          else:
              print("Appending logs to", path)
  
      writer = _state["writer"]
      if writer is not None:
          writer.writerow(fields)
  
file_path: moolib/py/moolib/examples/a2c.py
imports: import csv
  import os
  import time
  import gym
  import torch
  from torch import nn
  from torch.nn import functional
  import moolib
label_desc: Use image node_id 1 for calling a global function with example usage: log_to_file(_state) without return types