code: def _k_init(
      X, n_clusters, x_squared_norms, random_state, n_local_trials=None
  ):
      """Init n_clusters seeds according to k-means++
  
      Parameters
      ----------
      X : array or sparse matrix, shape (n_samples, n_features)
          The data to pick seeds for. To avoid memory copy, the input data
          should be double precision (dtype=np.float64).
  
      n_clusters : integer
          The number of seeds to choose
  
      x_squared_norms : array, shape (n_samples,)
          Squared Euclidean norm of each data point.
  
      random_state : int, RandomState instance
          The generator used to initialize the centers. Use an int to make the
          randomness deterministic.
          See :term:`Glossary <random_state>`.
  
      n_local_trials : integer, optional
          The number of seeding trials for each center (except the first),
          of which the one reducing inertia the most is greedily chosen.
          Set to None to make the number of trials depend logarithmically
          on the number of seeds (2+log(k)); this is the default.
  
      Notes
      -----
      Selects initial cluster centers for k-mean clustering in a smart way
      to speed up convergence. see: Arthur, D. and Vassilvitskii, S.
      "k-means++: the advantages of careful seeding". ACM-SIAM symposium
      on Discrete algorithms. 2007
  
      Version ported from http://www.stanford.edu/~darthur/kMeansppTest.zip,
      which is the implementation used in the aforementioned paper.
      """
      op = KMeansPlusPlusInit(
          x=X,
          n_clusters=n_clusters,
          x_squared_norms=x_squared_norms,
          state=random_state,
          n_local_trials=n_local_trials,
      )
      return op()
  
imports: import inspect
  import numpy
  from ...None import opcodes
  from ...None import tensor
  from ...core import OutputType, recursive_tile
  from ...core.operand import OperandStage
  from ...serialization.serializables import KeyField, Int32Field
  from ...tensor.array_utils import as_same_device, device
  from ...tensor.core import TensorOrder
  from ...tensor.random import RandomStateField
  from ...utils import has_unknown_shape
  from ..metrics import euclidean_distances
  from ..operands import LearnOperand, LearnOperandMixin
label_desc: Use image node_id 2 for calling a global function with example usage: _k_init(X, n_clusters, x_squared_norms, random_state, n_local_trials) and returns: op