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: sample the indicator and parameters
  
  Parameters
  ----------
  x: array of shape (n_samples, self.dim)
     the data used in the estimation process
  niter: int,
         the number of iterations to perform
  sampling_points: array of shape(nbpoints, self.dim), optional
                   points where the likelihood will be sampled
                   this defaults to x
  kfold: int or array, optional,
         parameter of cross-validation control
         by default, no cross-validation is used
         the procedure is faster but less accurate
  verbose=0: verbosity mode
  
  Returns
  -------
  likelihood: array of shape(nbpoints)
              total likelihood of the model
docstr_tok: ["sample","the","indicator","and","parameters","Parameters","--","--","--","--","--","x",":","array","of","shape","(","n_samples",",","self.dim",")","the","data","used","in","the","estimation","process","niter",":","int",",","the","number","of","iterations","to","perform","sampling_points",":","array","of","shape","(","nbpoints",",","self.dim",")",",","optional","points","where","the","likelihood","will","be","sampled","this","defaults","to","x","kfold",":","int","or","array",",","optional",",","parameter","of","cross-validation","control","by","default",",","no","cross-validation","is","used","the","procedure","is","faster","but","less","accurate","verbose=0",":","verbosity","mode","Returns","--","--","--","-","likelihood",":","array","of","shape","(","nbpoints",")","total","likelihood","of","the","model"]
code: def sample(
      self,
      x,
      niter=1,
      sampling_points=None,
      init=False,
      kfold=None,
      verbose=0,
  ):
      """sample the indicator and parameters
  
      Parameters
      ----------
      x: array of shape (n_samples, self.dim)
         the data used in the estimation process
      niter: int,
             the number of iterations to perform
      sampling_points: array of shape(nbpoints, self.dim), optional
                       points where the likelihood will be sampled
                       this defaults to x
      kfold: int or array, optional,
             parameter of cross-validation control
             by default, no cross-validation is used
             the procedure is faster but less accurate
      verbose=0: verbosity mode
  
      Returns
      -------
      likelihood: array of shape(nbpoints)
                  total likelihood of the model
      """
      self.check_x(x)
      if sampling_points is None:
          average_like = np.zeros(x.shape[0])
      else:
          average_like = np.zeros(sampling_points.shape[0])
          splike = self.likelihood_under_the_prior(sampling_points)
  
      plike = self.likelihood_under_the_prior(x)
  
      if init:
          self.k = 1
          z = np.zeros(x.shape[0])
          self.update(x, z)
  
      like = self.likelihood(x, plike)
      z = self.sample_indicator(like)
  
      for i in range(niter):
          if kfold is None:
              like = self.simple_update(x, z, plike)
          else:
              like = self.cross_validated_update(x, z, plike, kfold)
  
          if sampling_points is None:
              average_like += like
          else:
              average_like += np.sum(
                  self.likelihood(sampling_points, splike), 1
              )
  
      average_like /= niter
      return average_like
  
imports: import math
  import numpy
  from scipy.special import gammaln
  from .bgmm import BGMM, detsh
label_desc: Use image node_id 4 for calling the IMM obj's underlying member method code with example usage: obj.sample(x, niter, sampling_points, init, kfold, verbose) and returns: average_like