code: def _kpp(data, k):
      """Picks k points in data based on the kmeans++ method
  
      Parameters
      ----------
      data : ndarray
          Expect a rank 1 or 2 array. Rank 1 are assumed to describe one
          dimensional data, rank 2 multidimensional data, in which case one
          row is one observation.
      k : int
          Number of samples to generate.
  
      Returns
      -------
      init : ndarray
          A 'k' by 'N' containing the initial centroids
  
      References
      ----------
      .. [1] D. Arthur and S. Vassilvitskii, "k-means++: the advantages of
         careful seeding", Proceedings of the Eighteenth Annual ACM-SIAM Symposium
         on Discrete Algorithms, 2007.
      """
  
      dims = data.shape[1] if len(data.shape) > 1 else 1
      init = np.ndarray((k, dims))
  
      for i in range(k):
          if i == 0:
              init[i, :] = data[np.random.randint(dims)]
  
          else:
              D2 = np.array(
                  [
                      min(
                          [
                              np.inner(init[j] - x, init[j] - x)
                              for j in range(i)
                          ]
                      )
                      for x in data
                  ]
              )
              probs = D2 / D2.sum()
              cumprobs = probs.cumsum()
              r = np.random.rand()
              init[i, :] = data[np.searchsorted(cumprobs, r)]
  
      return init
  
imports: from __future__ import division, print_function, absolute_import
  import warnings
  import numpy
  from collections import deque
  from scipy._lib._util import _asarray_validated
  from scipy._lib.six import xrange
  from scipy.spatial.distance import cdist
  from .None import _vq
label_desc: Use image node_id 8 for calling a global function with example usage: _kpp(data, k) and returns: init