code: def mode(keys, axis=semantics.axis_default, weights=None, return_indices=False):
      
      index = as_index(keys, axis)
      if weights is None:
          unique, weights = count(index)
      else:
          unique, weights = group_by(index).sum(weights)
      bin = np.argmax(weights)
      _mode = unique[bin]     # FIXME: replace with index.take for lexindex compatibility?
      if return_indices:
          indices = index.sorter[index.start[bin]: index.stop[bin]]
          return _mode, indices
      else:
          return _mode
docs: compute the mode, or most frequent occuring key in a set
  
      Parameters
      ----------
      keys : ndarray, [n_keys, ...]
          input array. elements of 'keys' can have arbitrary shape or dtype
      weights : ndarray, [n_keys], optional
          if given, the contribution of each key to the mode is weighted by the given weights
      return_indices : bool
          if True, return all indices such that keys[indices]==mode holds
  
      Returns
      -------
      mode : ndarray, [...]
          the most frequently occuring key in the key sequence
      indices : ndarray, [mode_multiplicity], int, optional
          if return_indices is True, all indices such that points[indices]==mode holds