code: def convertlabels(ys, indices=None):
      """convert labels based on multiple variables or string labels to unique
      index labels 0,1,2,...,nk-1 where nk is the number of distinct labels
      """
      if indices is None:
          ylabel = ys
      else:
          idx = np.array(indices)
          if idx.size > 1 and ys.ndim == 2:
              ylabel = np.array(
                  ["@%s@" % ii[:2].tostring() for ii in ys]
              )[:, np.newaxis]
              # alternative
          ##        if ys[:,idx].dtype.kind == 'S':
          ##            ylabel = nd.array([' '.join(ii[:2]) for ii in ys])[:,np.newaxis]
          else:
              # there might be a problem here
              ylabel = ys
  
      unil, unilinv = np.unique(
          ylabel, return_index=False, return_inverse=True
      )
      return unilinv, np.arange(len(unil)), unil
  
file_path: statsmodels/statsmodels/sandbox/regression/try_catdata.py
imports: from statsmodels.compat.python import lrange
  import numpy
  from scipy import ndimage
label_desc: Use image node_id 5 for calling a global function with example usage: convertlabels(ys, indices) and returns: unilinv,  np,  unil