code: def iter_with_optional(data, preds, confs, labels, meta, idxs=None):
      # If this is a single example
      if type(data) not in [list, np.array, np.ndarray]:
          return [(data, preds, confs, labels, meta)]
      if type(meta) not in [list, np.array, np.ndarray]:
          meta = itertools.repeat(meta)
      else:
          if len(meta) != len(data):
              raise (
                  Exception("If meta is list, length must match data")
              )
      if type(labels) not in [list, np.array, np.ndarray]:
          labels = itertools.repeat(labels)
      else:
          if len(labels) != len(data):
              raise (
                  Exception("If labels is list, length must match data")
              )
      ret = zip(data, preds, confs, labels, meta)
      if idxs is not None:
          ret = list(ret)
          ret = [ret[i] for i in idxs]
      return ret
  
imports: import numpy
  import itertools
label_desc: Use image node_id 1 for calling a global function with example usage: iter_with_optional(data, preds, confs, labels, meta, idxs) and returns: ret, list