code: def _idx_col2rowm(d):
      
      if 0 == len(d):
          return 1
      if 1 == len(d):
          return np.arange(d[0])
      # order='F' indicates column-major ordering
      idx = np.array(np.arange(np.prod(d))).reshape(d, order='F').T
      return idx.flatten(order='F')
docs: Generate indexes to change from col-major to row-major ordering