class_docstr: The class implements Infinite Gaussian Mixture model
  or Dirichlet Process Mixture model.
  This is simply a generalization of Bayesian Gaussian Mixture Models
  with an unknown number of classes.
class_docstr_tok: ["The","class","implements","Infinite","Gaussian","Mixture","model","or","Dirichlet","Process","Mixture","model",".","This","is","simply","a","generalization","of","Bayesian","Gaussian","Mixture","Models","with","an","unknown","number","of","classes","."]
docstr: Reduce the assignments by removing empty clusters and update self.k
  
  Parameters
  ----------
  z: array of shape(n),
     a vector of membership variables changed in place
  
  Returns
  -------
  z: the remapped values
docstr_tok: ["Reduce","the","assignments","by","removing","empty","clusters","and","update","self.k","Parameters","--","--","--","--","--","z",":","array","of","shape","(","n",")",",","a","vector","of","membership","variables","changed","in","place","Returns","--","--","--","-","z",":","the","remapped","values"]
code: def reduce(self, z):
      """Reduce the assignments by removing empty clusters and update self.k
  
      Parameters
      ----------
      z: array of shape(n),
         a vector of membership variables changed in place
  
      Returns
      -------
      z: the remapped values
      """
      uz = np.unique(z[z > -1])
      for i, k in enumerate(uz):
          z[z == k] = i
      self.k = z.max() + 1
      return z
  
imports: import math
  import numpy
  from scipy.special import gammaln
  from .bgmm import BGMM, detsh
label_desc: Use image node_id 7 for calling the IMM obj's underlying member method code with example usage: obj.reduce(z) and returns: z