code: def topk(
      data,
      axis=-1,
      k=1,
      ret_typ="indices",
      is_ascend=False,
      dtype="float32",
  ):
      r"""Returns the indices of the top *k* elements in an input array along the given
       axis (by default).
       If ret_type is set to 'value' returns the value of top *k* elements (instead of indices).
       In case of ret_type = 'both', both value and index would be returned.
       The returned elements will be sorted.
  
      Parameters
      ----------
      data : NDArray
          The input array
      axis : int or None, optional, default='-1'
          Axis along which to choose the top k indices.
          If not given, the flattened array is used. Default is -1.
      k : int, optional, default='1'
          Number of top elements to select, should be always smaller than or equal to
          the element number in the given axis. A global sort is performed if set k < 1.
      ret_typ : {'both', 'indices', 'mask', 'value'},optional, default='indices'
          The return type.
       "value" means to return the top k values,
       "indices" means to return the indices of the top k values,
       "mask" means to return a mask array containing 0 and 1. 1 means the top k values.
       "both" means to return a list of both values and indices of top k elements.
      is_ascend : boolean, optional, default=0
          Whether to choose k largest or k smallest elements.
          Top K largest elements will be chosen if set to false.
      dtype : {'float16', 'float32', 'float64', 'int32', 'int64', 'uint8'},
              optional, default='float32'
          DType of the output indices when ret_typ is "indices" or "both".
          An error will be raised if the selected data type cannot precisely represent the indices.
  
      Returns
      -------
      out : NDArray or list of NDArrays
          The output of this function.
  
      Example
      -------
      >>> x = np.array([[0.3, 0.2, 0.4], [0.1, 0.3, 0.2]])
  
      returns an index of the largest element on last axis
  
      >>> npx.topk(x)
      array([[2.],
             [1.]])
  
      returns the value of top-2 largest elements on last axis
  
      >>> npx.topk(x, ret_typ='value', k=2)
      array([[0.4, 0.3],
             [0.3, 0.2]])
  
      returns the value of top-2 smallest elements on last axis
  
      >>> npx.topk(x, ret_typ='value', k=2, is_ascend=1)
      array([[0.2, 0.3],
             [0.1, 0.2]])
  
      returns the value of top-2 largest elements on axis 0
  
      >>> npx.topk(x, axis=0, ret_typ='value', k=2)
      array([[0.3, 0.3, 0.4],
             [0.1, 0.2, 0.2]])
  
      flattens and then returns list of both values and indices
  
      >>> npx.topk(x, ret_typ='both', k=2)
      [array([[0.4, 0.3], [0.3, 0.2]]),
       array([[2., 0.], [1., 2.]])]
      """
      out = _api_internal.topk(data, axis, k, ret_typ, is_ascend, dtype)
      if isinstance(out, NDArrayBase):
          return out
      return list(out)
  
imports: import numpy
  from .._internal import NDArrayBase
  from .None import _api_internal
  from ...util import set_module
  from ..ndarray import get_dtype_name
label_desc: Use image node_id 16 for calling a global function with example usage: topk(data, axis, k, ret_typ, is_ascend, dtype) and returns: list, out