code: def write_raw_file(mon, log_file="paramlog.py", **kwds):
      """write parameter and solution trajectory to a log file in 'raw' format
  
      mon is a monitor; log_file is a str log file path, with format:
  
      # header
      id = ...
      params = ...
      cost = ...
  
      `id` is a tuple of (iteration, id), with `id` an int or None
      `params` is a list[float], and is the input to the cost function
      `cost` is a float or tuple[float], and is the output of the cost function
  
      if header is provided, then the given string is written as the file header
      all other kwds are written as file entries
      """
      if isNull(mon):
          return  # XXX: throw error? warning? ???
      steps, energy, ids = read_monitor(mon, id=True)
      if not len(ids):  # XXX: is manipulating ids a good idea?
          ids = None
      elif ids.count(ids[0]) == len(
          ids
      ):  # XXX: generally, all None or all ints
          ids = ids[0]
      f = open(log_file, "w")
      if "header" in kwds:
          f.write("# %s\n" % kwds["header"])
          del kwds["header"]
      f.write("inf = float('inf')\n")  # define special values
      f.write("nan = float('nan')\n")  # define special values
      for variable, value in kwds.items():
          f.write(
              "%s = %s\n" % (variable, value)
          )  # write remaining kwds as variables
      if ids is not None:
          f.write("id = %s\n" % ids)
      # f.write('# %s\n' % energy[-1])
      f.write("params = %s\n" % steps)
      f.write("cost = %s\n" % energy)
      f.close()
      return
  
imports: from mystic.tools import list_or_tuple_or_ndarray
  from mystic.tools import isNull
  import sys
label_desc: Use image node_id 11 for calling a global function with example usage: write_raw_file(mon, log_file) without return types