code: def tile(cls, op: "KMeansScalablePlusPlusInit"):
      if has_unknown_shape(*op.inputs):
          yield
  
      x = mt.tensor(op.x)
      x_squared_norms = mt.atleast_2d(op.x_squared_norms)
      out = op.outputs[0]
  
      random_state = op.state
      rs = mt.random.RandomState.from_numpy(random_state)
  
      n_samples, n_features = x.shape
      n_clusters = op.n_clusters
  
      # step 1, sample a centroid
      centers = x[random_state.randint(n_samples, size=1)]
  
      for _ in range(op.init_iter):
          distances = euclidean_distances(
              x, centers, X_norm_squared=x_squared_norms, squared=True
          )
  
          # calculate the cost of data with respect to current centers
          cost = mt.sum(mt.min(distances, axis=1))
  
          # calculate the distribution to sample new centers
          distribution = mt.full(len(distances), 1 / len(distances))
          mt.true_divide(
              mt.min(distances, axis=1),
              cost,
              where=cost != 0,
              out=distribution,
          )
  
          # pick new centers
          new_centers_size = op.oversampling_factor * n_clusters
          new_centers = x[
              rs.choice(n_samples, new_centers_size, p=distribution)
          ]
  
          centers = mt.concatenate([centers, new_centers])
  
      # rechunk centers into one chunk
      centers = (yield from recursive_tile(centers)).rechunk(
          centers.shape
      )
  
      distances = yield from recursive_tile(
          euclidean_distances(
              x, centers, X_norm_squared=x_squared_norms, squared=True
          )
      )
  
      map_index_to_chunks = {}
      # calculate weight for each chunk
      for c in distances.chunks:
          map_chunk_op = KMeansScalablePlusPlusInit(
              stage=OperandStage.map
          )
          map_chunk_kw = {
              "shape": (len(centers),),
              "dtype": np.dtype(np.int64),
              "order": TensorOrder.C_ORDER,
              "index": c.index,
          }
          map_chunk = map_chunk_op.new_chunk([c], kws=[map_chunk_kw])
          map_index_to_chunks[c.index] = map_chunk
  
      combine_chunks = []
      for i in range(distances.chunk_shape[0]):
          map_chunks = [
              map_index_to_chunks[i, j]
              for j in range(distances.chunk_shape[1])
          ]
          combine_chunk_op = KMeansScalablePlusPlusInit(
              stage=OperandStage.combine
          )
          combine_chunk_kw = {
              "shape": (len(centers),),
              "dtype": np.dtype(np.int64),
              "order": TensorOrder.C_ORDER,
              "index": (i,),
          }
          combine_chunk = combine_chunk_op.new_chunk(
              map_chunks, kws=[combine_chunk_kw]
          )
          combine_chunks.append(combine_chunk)
  
      reduce_chunk_op = KMeansScalablePlusPlusInit(
          n_clusters=op.n_clusters,
          state=random_state,
          stage=OperandStage.reduce,
      )
      reduce_chunk_kw = out.params
      reduce_chunk_kw["index"] = (0, 0)
      reduce_chunk = reduce_chunk_op.new_chunk(
          [centers.chunks[0]] + combine_chunks, kws=[reduce_chunk_kw]
      )
  
      new_op = op.copy()
      kw = out.params
      kw["chunks"] = [reduce_chunk]
      kw["nsplits"] = tuple((s,) for s in out.shape)
      return new_op.new_tileables(op.inputs, kws=[kw])
  
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 10 for calling the KMeansScalablePlusPlusInit obj's underlying member method code with example usage: obj.tile(cls, op) and returns: new_op