code: def _gen_topk_chunk(
      cls,
      input_chunk,
      op,
      is_terminate_node,
      axis_offset=None,
      chunk_index=None,
  ):
      chunk_op = op.copy().reset_key()
      if axis_offset is not None:
          chunk_op._axis_offset = axis_offset
      if not is_terminate_node:
          # no need to sort if not the terminated node
          chunk_op._sorted = False
      shape = list(input_chunk.shape)
      shape[op.axis] = min(op.k, input_chunk.shape[op.axis])
      if not is_terminate_node:
          # whenever return_indices, value is required
          chunk_op._return_value = True
          if axis_offset is not None:
              chunk_op.stage = OperandStage.map
          else:
              chunk_op.stage = OperandStage.combine
          return chunk_op.new_chunk(
              [input_chunk],
              shape=tuple(shape),
              order=input_chunk.order,
              index=chunk_index,
          )
      else:
          chunk_op.stage = OperandStage.agg
          kws = []
          if op.return_value:
              kws.append(
                  {
                      "shape": tuple(shape),
                      "order": input_chunk.order,
                      "dtype": input_chunk.dtype,
                      "index": chunk_index,
                      "type": "topk",
                  }
              )
          if op.return_indices:
              kws.append(
                  {
                      "shape": tuple(shape),
                      "order": TensorOrder.C_ORDER,
                      "dtype": np.dtype(np.int64),
                      "index": chunk_index,
                      "type": "argtopk",
                  }
              )
          return chunk_op.new_chunks([input_chunk], kws=kws)
  
imports: import itertools
  import numpy
  from ...None import opcodes
  from ...config import options
  from ...core import ExecutableTuple, recursive_tile
  from ...core.operand import OperandStage
  from ...serialization.serializables import FieldTypes, KeyField, Int64Field, Int32Field, BoolField, StringField, ListField
  from ...utils import ceildiv, flatten
  from ..array_utils import as_same_device, device
  from ..core import TensorOrder
  from ..datasource import tensor
  from ..operands import TensorOperand, TensorOperandMixin
  from ..utils import validate_axis, validate_order
  from .sort import _validate_sort_psrs_kinds
label_desc: Use image node_id 18 for calling the TensorTopk obj's underlying member method code with example usage: obj._gen_topk_chunk(cls, input_chunk, op, is_terminate_node, axis_offset, chunk_index) and returns: chunk_op, chunk_op