code: def write_monitor(steps, energy, id=None, k=None):
      """write trajectories to a monitor instance
  
      `steps` is a list[float], and is the input to the cost function
      `energy` is a float or tuple[float], and is the output of the cost function
      `id` is a list[int], and is the `id` of the monitored object
      `k` is float multiplier on `energy` (e.g. k=-1 inverts the cost function)
  
      Returns a mystic.monitors.Monitor instance
      """
      from mystic.monitors import Monitor
  
      mon = Monitor()
      mon.k = k
      mon._x.extend(steps)
      mon._y.extend(mon._k(energy, iter))
      if id is not None:
          mon._id.extend(id)
      return mon
  
imports: from mystic.tools import list_or_tuple_or_ndarray
  from mystic.tools import isNull
  import sys
label_desc: Use image node_id 7 for calling a global function with example usage: write_monitor(steps, energy, id, k) and returns: mon