code: def agg_dims(arr, stat):
      
      axis = None
      if arr.ndim > 2:
          axis = 1
          arr = arr.reshape(arr.shape[0], -1)
      module = np.ma if hasattr(arr, 'mask') else np
      return getattr(module, stat)(arr, axis)
docs: Returns a 1D array with higher dimensions aggregated using stat fn.
  
      Arguments:
      arr -- ndarray
      stat -- numpy or numpy.ma function as str to call