code: def logfile_reader(filename, iter=False):
      """read a log file (e.g. written by a LoggingMonitor) in three-column format
  
      iter is a bool, where if True, `iter` is also returned
      filename is a log file path, with format:
  
      `__iter__  __energy__  __params__`
  
      `iter` is a tuple of (iteration, id), with `id` an int or None
      `energy` is a float or tuple[float], and is the output of the cost function
      `params` is a list[float], and is the input to the cost function
  
      If iter=True, returns tuple of (iter, params, energy), as defined above.
      If iter=False, returns tuple of (params, energy).
      """
      from numpy import inf, nan
  
      f = open(filename, "r")
      file = f.read()
      f.close()
      contents = file.split("\n")
      # parse file contents to get (i,id), cost, and parameters
      step = []
      cost = []
      param = []
      for line in contents[:-1]:
          if line.startswith(("#", "inf =", "nan =")):
              pass
          else:
              values = line.split("   ")
              step.append(eval(values[0]))  # XXX: yields (i,id)
              cost.append(eval(values[1]))
              param.append(eval(values[2]))
      return (step, param, cost) if iter else (param, cost)
  
imports: from mystic.tools import list_or_tuple_or_ndarray
  from mystic.tools import isNull
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: logfile_reader(filename, iter) and returns: unknown