code: def execute(cls, ctx, op: "KMeansElkanUpdate"):
      if op.stage == OperandStage.reduce:
          return cls._execute_reduce(ctx, op)
      else:
          (
              (
                  x,
                  sample_weight,
                  centers_old,
                  center_half_distances,
                  distance_next_center,
                  labels,
                  upper_bounds,
                  lower_bounds,
              ),
              device_id,
              xp,
          ) = as_same_device(
              [ctx[inp.key] for inp in op.inputs],
              device=op.device,
              ret_extra=True,
              copy_if_not_writeable=True,
          )
  
          with device(device_id):
              if not op.update_centers:
                  centers_new = centers_old.copy()
              else:
                  centers_new = np.zeros_like(centers_old)
              weight_in_clusters = np.zeros(
                  op.n_clusters, dtype=x.dtype
              )
  
              if xp is np:
                  method = update_chunk_dense
              elif xp is sparse:
                  method = update_chunk_sparse
              else:  # pragma: no cover
                  raise NotImplementedError(
                      "Does not support run on GPU"
                  )
  
              out_labels, out_upper_bounds, out_lower_bounds = (
                  labels.copy(),
                  upper_bounds.copy(),
                  lower_bounds.copy(),
              )
              method(
                  x,
                  sample_weight,
                  centers_old,
                  center_half_distances,
                  distance_next_center,
                  out_labels,
                  out_upper_bounds,
                  out_lower_bounds,
                  centers_new,
                  weight_in_clusters,
                  op.update_centers,
              )
  
              # labels
              ctx[op.outputs[0].key] = out_labels
              # upper_bounds
              ctx[op.outputs[1].key] = out_upper_bounds
              # lower_bounds
              ctx[op.outputs[2].key] = out_lower_bounds
              # centers_new
              ctx[op.outputs[3].key] = centers_new
              # weight_in_cluster
              ctx[op.outputs[4].key] = weight_in_clusters
  
imports: import numpy
  from ...None import opcodes
  from ...core import OutputType, recursive_tile
  from ...core.operand import OperandStage
  from ...serialization.serializables import KeyField, Int32Field, BoolField
  from ...tensor.array_utils import as_same_device, device, cp, sparse
  from ...tensor.core import TensorOrder
  from ...utils import has_unknown_shape
  from ..operands import LearnOperand, LearnOperandMixin
  from ._k_means_common import _execute_merge_update, _relocate_empty_clusters
  from ._k_means_elkan import init_bounds_dense, init_bounds_sparse, update_chunk_dense, update_chunk_sparse
  from ._k_means_fast import update_center, update_upper_lower_bounds
label_desc: Use image node_id 18 for calling the KMeansElkanUpdate obj's underlying member method code with example usage: obj.execute(cls, ctx, op) and returns: cls