code: def data_generator(data, iterable=None):
      """Return generator for ``[(i, data[i]) for i in iterable]``
  
      If iterable is None, it defaults to range(data.shape[0])
  
      Examples
      --------
      >>> a = np.asarray([[True,False],[False,True]])
      >>> b = np.asarray([[False,False],[True,False]])
  
      >>> for i, d in data_generator(np.asarray([[1,2],[3,4]]), [a,b]):
      ...     print(d)
      ...
      [1 4]
      [3]
      """
      data = np.asarray(data)
      if iterable is None:
          iterable = range(data.shape[0])
      for index in iterable:
          yield index, data[index]
  
file_path: nipy/nipy/core/utils/generators.py
imports: import numpy
  from nipy.utils import seq_prod
label_desc: Use image node_id 2 for calling a global function with example usage: data_generator(data, iterable) without return types