code: def co_labelling(z, kmax=None, kmin=None):
      """
      return a sparse co-labelling matrix given the label vector z
  
      Parameters
      ----------
      z: array of shape(n_samples),
         the input labels
      kmax: int, optional,
            considers only the labels in the range [0, kmax[
  
      Returns
      -------
      colabel: a sparse coo_matrix,
               yields the co labelling of the data
               i.e. c[i,j]= 1 if z[i]==z[j], 0 otherwise
      """
      from scipy.sparse import coo_matrix
  
      n = z.size
      colabel = coo_matrix((n, n))
  
      if kmax is None:
          kmax = z.max() + 1
  
      if kmin is None:
          kmin = z.min() - 1
  
      for k in np.unique(z):
          if (k < kmax) & (k > kmin):
              i = np.array(np.nonzero(z == k))
              row = np.repeat(i, i.size)
              col = np.ravel(np.tile(i, i.size))
              data = np.ones((i.size) ** 2)
              colabel = colabel + coo_matrix(
                  (data, (row, col)), shape=(n, n)
              )
      return colabel
  
imports: import math
  import numpy
  from scipy.special import gammaln
  from .bgmm import BGMM, detsh
label_desc: Use image node_id 1 for calling a global function with example usage: co_labelling(z, kmax, kmin) and returns: colabel