code: def generate_output(outputs, iterable, reshape=lambda x, y: (x, y)):
      """
      Write out results of a given output.
  
      In the regression setting, results is generally going to be a
      scipy.stats.models.model.LikelihoodModelResults instance.
  
      Parameters
      ----------
      outputs : sequence
          sequence of output objects
      iterable : object
          Object which iterates, returning tuples of (indexer, results), where
          ``indexer`` can be used to index into the `outputs`
      reshape : callable
          accepts two arguments, first is the indexer, and the second is the array
          which will be indexed; returns modified indexer and array ready for
          slicing with modified indexer.
      """
      for indexer, results in iterable:
          for output in outputs:
              # Might be regression output object
              if not hasattr(output, "list"):  # lame test here
                  k, d = reshape(indexer, output(results))
                  output[k] = d
              else:
                  # or a regression output list (like a TOutput, with several
                  # images to output to)
                  r = output(results)
                  for j, l in enumerate(output.list):
                      k, d = reshape(indexer, r[j])
                      l[k] = d
      # flush outputs, if necessary
      for output in outputs:
          if isinstance(output, outputters.RegressionOutput):
              if hasattr(output.img, "save"):
                  output.img.save()
          elif isinstance(output, outputters.RegressionOutputList):
              for im in output.list:
                  if hasattr(im, "save"):
                      im.save()
  
imports: import copy
  from os import path
  import numpy
  import numpy.linalg
  from nipy.algorithms.statistics.formula import make_recarray
  from nipy.algorithms.statistics.models.regression import ARModel, OLSModel, ar_bias_correct, ar_bias_corrector
  from nipy.core.api import AffineTransform, Image, matrix_generator, parcels
  from nipy.io.api import save_image
  from ..api import FmriImageList, axis0_generator
  from .None import outputters
label_desc: Use image node_id 8 for calling a global function with example usage: generate_output(outputs, iterable, reshape) without return types