code: def combine_indices(groups, prefix="", sep=".", return_labels=False):
      """use np.unique to get integer group indices for product, intersection"""
      if isinstance(groups, tuple):
          groups = np.column_stack(groups)
      else:
          groups = np.asarray(groups)
  
      dt = groups.dtype
  
      is2d = groups.ndim == 2  # need to store
  
      if is2d:
          ncols = groups.shape[1]
          if not groups.flags.c_contiguous:
              groups = np.array(groups, order="C")
  
          groups_ = groups.view([("", groups.dtype)] * groups.shape[1])
      else:
          groups_ = groups
  
      uni, uni_idx, uni_inv = np.unique(
          groups_, return_index=True, return_inverse=True
      )
  
      if is2d:
          uni = uni.view(dt).reshape(-1, ncols)
  
          # avoiding a view would be
          # for t in uni.dtype.fields.values():
          #     assert (t[0] == dt)
          #
          # uni.dtype = dt
          # uni.shape = (uni.size//ncols, ncols)
  
      if return_labels:
          label = [
              (prefix + sep.join(["%s"] * len(uni[0]))) % tuple(ii)
              for ii in uni
          ]
          return uni_inv, uni_idx, uni, label
      else:
          return uni_inv, uni_idx, uni
  
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 1 for calling a global function with example usage: combine_indices(groups, prefix, sep, return_labels) and returns: uni_inv,  uni_idx,  uni,  label, uni_inv,  uni_idx,  uni