code: def matrix_generator(img):
      """
      From a generator of items (i, r), return
      (i, rp) where rp is a 2d array with rp.shape = (r.shape[0], prod(r.shape[1:]))
      """
      for i, r in img:
          rp = np.reshape(r, (r.shape[0], np.prod(r.shape[1:])))
          yield i, rp
  
file_path: nipy/nipy/core/utils/generators.py
imports: import numpy
  from nipy.utils import seq_prod
label_desc: Use image node_id 7 for calling a global function with example usage: matrix_generator(img) without return types