code: def read_trajectories(source, iter=False):
      """read trajectories from a monitor instance or three-column format log file
  
      iter is a bool, where if True, `iter` is also returned
      source is a monitor instance or 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).
      """
      if isinstance(source, str):
          return logfile_reader(source, iter)
      param, cost = source.x, source.y
      if not iter:
          return param, cost
      # otherwise, id may need some processing...
      return _process_ids(source.id, len(cost)), 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 3 for calling a global function with example usage: read_trajectories(source, iter) and returns: _process_ids,  param,  cost, logfile_reader, param,  cost