code: def top_k(
      x: np.ndarray,
      k: int,
      /,
      *,
      axis: int = -1,
      largest: bool = True,
      sorted: bool = True,
      out: Optional[Tuple[np.ndarray, np.ndarray]] = None,
  ) -> Tuple[np.ndarray, np.ndarray]:
      k = min(k, x.shape[axis])
      if not largest:
          indices = np.argsort(x, axis=axis)
          indices = np.take(indices, np.arange(k), axis=axis)
      else:
          indices = np.argsort(-x, axis=axis)
          indices = np.take(indices, np.arange(k), axis=axis)
      if not sorted:
          indices = np.sort(indices, axis=axis)
      topk_res = NamedTuple(
          "top_k", [("values", np.ndarray), ("indices", np.ndarray)]
      )
      val = np.take_along_axis(x, indices, axis=axis)
      return topk_res(val, indices)
  
imports: from typing import Iterable, Optional, Union, Sequence, Tuple, NamedTuple, Literal, Callable, Any, List
  from numbers import Number
  from collections import namedtuple
  import numpy
  import ivy
  from ivy.functional.backends.numpy.helpers import _scalar_output_to_0d_array
  from ivy.func_wrapper import with_supported_dtypes
  from .None import backend_version
label_desc: Use image node_id 7 for calling a global function with example usage: top_k() and returns: topk_res