code: def model_generator(
      formula,
      data,
      volume_start_times,
      iterable=None,
      slicetimes=None,
      model_type=OLSModel,
      model_params=lambda x: (),
  ):
      """
      Generator for the models for a pass of fmristat analysis.
      """
      volume_start_times = make_recarray(
          volume_start_times.astype(float), "t"
      )
      # Generator for slices of the data with time as first axis
      axis0_gen = axis0_generator(data, slicers=iterable)
      # Iterate over 2D slices of the data
      for indexer, indexed_data in matrix_generator(axis0_gen):
          model_args = model_params(indexer)  # model may depend on i
          # Get the design for these volume start times
          design = formula.design(volume_start_times, return_float=True)
          # Make the model from the design
          rmodel = model_type(design, *model_args)
          yield indexer, indexed_data, rmodel
  
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 1 for calling a global function with example usage: model_generator(formula, data, volume_start_times, iterable, slicetimes, model_type, model_params) without return types