docstr: Apply function to each group. Similar to transform_array but does
  not coerce array to a DataFrame and back and only works on a 1D or 2D
  numpy array. function is called function(group, group_idx, **kwargs).
docstr_tok: ["Apply","function","to","each","group",".","Similar","to","transform_array","but","does","not","coerce","array","to","a","DataFrame","and","back","and","only","works","on","a","1D","or","2D","numpy","array",".","function","is","called","function","(","group",",","group_idx",",","*","*","kwargs",")","."]
code: def transform_slices(self, array, function, level=0, **kwargs):
      """Apply function to each group. Similar to transform_array but does
      not coerce array to a DataFrame and back and only works on a 1D or 2D
      numpy array. function is called function(group, group_idx, **kwargs).
      """
      array = np.asarray(array)
      if array.shape[0] != self.nobs:
          raise Exception("array does not have the same shape as index")
      # always reset because level is given. need to refactor this.
      self.get_slices(level=level)
      processed = []
      for s in self.slices:
          if array.ndim == 2:
              subset = array[s, :]
          elif array.ndim == 1:
              subset = array[s]
          processed.append(function(subset, s, **kwargs))
      processed = np.array(processed)
      return processed.reshape(-1, processed.shape[-1])
  
imports: from statsmodels.compat.python import lrange, lzip
  import numpy
  import pandas
  import statsmodels.tools.data
  from pandas import Index, MultiIndex
label_desc: Use image node_id 13 for calling the Grouping obj's underlying member method code with example usage: obj.transform_slices(array, function, level) and returns: processed