code: def _kmeans(
      X,
      nbclusters=2,
      Labels=None,
      maxiter=300,
      delta=1.0e-4,
      ninit=1,
      verbose=0,
  ):
      """kmeans clustering algorithm
  
      Parameters
      ----------
      X: array of shape (n,p): n = number of items, p = dimension
         data array
      nbclusters (int), the number of desired clusters
      Labels: array of shape (n) prior Labels, optional
              if None or inadequate a random initialization is performed.
      maxiter: int, optional
               the maximum number of iterations  before convergence
      delta: float, optional
             the relative increment in the results before declaring convergence.
      verbose=0: verboseity mode
  
      Returns
      -------
      Centers: array of shape (nbclusters, p),
               the centroids of  the resulting clusters
      Labels: array of size n, the discrete labels of the input items
      J, float,  the final value of the inertia criterion
      """
      # fixme: do the checks
      nbitem = X.shape[0]
  
      vdata = np.mean(np.var(X, 0))
      bJ = np.inf
      for it in range(ninit):
          # init
          if Labels is None:
              seeds = np.argsort(np.random.rand(nbitem))[:nbclusters]
              centers = X[seeds]
          else:
              centers = _MStep(X, Labels, nbclusters)
          centers_old = centers.copy()
  
          # iterations
          for i in range(maxiter):
              z, J = _EStep(X, centers)
              centers = _MStep(X, z, nbclusters)
              if verbose:
                  print(i, J)
              if np.sum((centers_old - centers) ** 2) < delta * vdata:
                  if verbose:
                      print(i)
                  break
              centers_old = centers.copy()
  
              if J < bJ:
                  bJ = J
                  centers_output = centers.copy()
                  z_output = z.copy()
      else:
          centers_output = centers
          z_output = z
  
      return centers_output, z_output, bJ
  
imports: import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: _kmeans(X, nbclusters, Labels, maxiter, delta, ninit, verbose) and returns: centers_output,  z_output,  bJ