code: def tile(cls, op: "PairwiseDistancesTopk"):
      X, Y = op.x, op.y
      k = op.k
  
      if X.chunk_shape[1] > 1:
          X = yield from recursive_tile(X.rechunk({1: X.shape[1]}))
  
      if has_unknown_shape(Y):
          yield
      if Y.chunk_shape[1] > 1:
          Y = yield from recursive_tile(Y.rechunk({1: Y.shape[1]}))
  
      out_distance_chunks, out_index_chunks = [], []
      y_acc_chunk_shapes = [0] + np.cumsum(Y.nsplits[0]).tolist()
      for i in range(len(range(X.chunk_shape[0]))):
          x_chunk = X.cix[i, 0]
          y_chunk_shape = Y.chunk_shape[0]
  
          if y_chunk_shape == 1:
              chunk_op = op.copy().reset_key()
              y_chunk = Y.chunks[0]
              o = cls._gen_out_chunks(x_chunk, y_chunk, chunk_op)
              if chunk_op.return_index:
                  out_distance_chunks.append(o[0])
                  out_index_chunks.append(o[1])
              else:
                  out_distance_chunks.append(o)
          else:
              to_concat_chunks = []
              concat_size = 0
              for j in range(y_chunk_shape):
                  y_chunk = Y.cix[j, 0]
                  chunk_op = op.copy().reset_key()
                  chunk_op._y_offset = y_acc_chunk_shapes[j]
                  chunk_op.stage = OperandStage.map
                  size = min(k, y_chunk.shape[0])
                  o = chunk_op.new_chunk(
                      [x_chunk, y_chunk],
                      shape=(x_chunk.shape[0], size),
                      order=TensorOrder.C_ORDER,
                      index=(i, j),
                  )
                  to_concat_chunks.append(o)
                  concat_size += size
  
              concat_op = TensorConcatenate(
                  axis=1, dtype=to_concat_chunks[0].dtype
              )
              concat = concat_op.new_chunk(
                  to_concat_chunks,
                  shape=(x_chunk.shape[0], concat_size),
                  order=TensorOrder.C_ORDER,
                  index=(i, 0),
              )
  
              chunk_op = op.copy().reset_key()
              chunk_op.stage = OperandStage.agg
              distance_params = {
                  "shape": (x_chunk.shape[0], k),
                  "order": TensorOrder.C_ORDER,
                  "dtype": np.dtype(np.float64),
                  "index": (i, 0),
                  "_type_": "distance",
              }
              if op.return_index:
                  index_params = {
                      "shape": (x_chunk.shape[0], k),
                      "order": TensorOrder.C_ORDER,
                      "dtype": np.dtype(np.int64),
                      "index": (i, 0),
                      "_type": "index",
                  }
                  distance_chunk, index_chunk = chunk_op.new_chunks(
                      [concat], kws=[distance_params, index_params]
                  )
                  out_distance_chunks.append(distance_chunk)
                  out_index_chunks.append(index_chunk)
              else:
                  out_distance_chunks.append(
                      chunk_op.new_chunk(
                          [concat], kws=[distance_params]
                      )
                  )
  
      new_op = op.copy()
      nsplits = (tuple(c.shape[0] for c in out_distance_chunks), (k,))
      params = [o.params for o in op.outputs]
      params[0]["chunks"] = out_distance_chunks
      params[0]["nsplits"] = nsplits
      if op.return_index:
          params[1]["chunks"] = out_index_chunks
          params[1]["nsplits"] = nsplits
      return new_op.new_tensors(op.inputs, kws=params)
  
imports: from functools import partial
  import numpy
  from ....None import opcodes
  from ....None import options
  from ....core import recursive_tile
  from ....core.operand import OperandStage
  from ....serialization.serializables import KeyField, BoolField, DictField, Int64Field, AnyField
  from ....tensor.core import TensorOrder
  from ....tensor.merge import TensorConcatenate
  from ....tensor.array_utils import as_same_device, device, get_array_module
  from ....utils import has_unknown_shape, ensure_own_data
  from ...utils import gen_batches, get_chunk_n_rows
  from ...utils.validation import _num_samples
  from .core import PairwiseDistances
label_desc: Use image node_id 14 for calling the PairwiseDistancesTopk obj's underlying member method code with example usage: obj.tile(cls, op) and returns: new_op