code: def _relocate_empty_clusters(
      X,
      sample_weight,
      centers_old,
      centers_new,
      weight_in_clusters,
      labels,
      to_run=None,
      session=None,
      run_kwargs=None,
  ):
      to_run = to_run or list()
      empty_clusters = mt.where(mt.equal(weight_in_clusters, 0))[
          0
      ].astype(mt.int32)
      to_run.append(empty_clusters)
  
      mt.ExecutableTuple(to_run).execute(
          session=session, **(run_kwargs or dict())
      )
  
      n_empty = empty_clusters.shape[0]
  
      if n_empty == 0:
          return centers_new, weight_in_clusters
  
      distances = (
          (mt.asarray(X) - mt.asarray(centers_old)[labels]) ** 2
      ).sum(axis=1)
      far_from_centers = mt.argpartition(distances, -n_empty)[
          : -n_empty - 1 : -1
      ].astype(np.int32)
  
      far_x = X[far_from_centers]
      far_labels = labels[far_from_centers]
      far_sample_weight = sample_weight[far_from_centers]
  
      op = KMeansRelocateEmptyClusters(
          empty_clusters=empty_clusters,
          far_x=far_x,
          far_labels=far_labels,
          far_sample_weights=far_sample_weight,
          centers_new=centers_new,
          weight_in_clusters=weight_in_clusters,
      )
      return op()
  
imports: import numpy
  from ...None import opcodes
  from ...None import tensor
  from ...core import OutputType, recursive_tile
  from ...serialization.serializables import KeyField
  from ...tensor.array_utils import as_same_device, device, sparse
  from ...tensor.core import TensorOrder
  from ...utils import has_unknown_shape
  from ..operands import LearnOperand, LearnOperandMixin
  from ._k_means_fast import _inertia_dense, _inertia_sparse, merge_update_chunks
label_desc: Use image node_id 3 for calling a global function with example usage: _relocate_empty_clusters(X, sample_weight, centers_old, centers_new, weight_in_clusters, labels, to_run, session, run_kwargs) and returns: op, centers_new,  weight_in_clusters