code: def top_k(
      x: torch.Tensor,
      k: int,
      /,
      *,
      axis: int = -1,
      largest: bool = True,
      sorted: bool = True,
      out: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      k = min(k, x.shape[axis])
      topk_res = NamedTuple(
          "top_k", [("values", torch.Tensor), ("indices", torch.Tensor)]
      )
      if not largest:
          indices = torch.argsort(x, dim=axis)
          indices = torch.index_select(indices, axis, torch.arange(k))
      else:
          indices = torch.argsort(-x, dim=axis)
          indices = torch.index_select(indices, axis, torch.arange(k))
      if not sorted:
          indices = torch.sort(indices, dim=axis)[0]
      val = torch.gather(x, axis, indices)
      return topk_res(val, indices)
  
imports: from typing import Iterable, Optional, Union, Sequence, Tuple, NamedTuple, List, Literal, Callable, Any
  from numbers import Number
  from collections import namedtuple
  import torch
  from ivy.func_wrapper import with_unsupported_dtypes, with_supported_dtypes
  from ..None import backend_version
  import ivy
  from ivy.functional.ivy.experimental.manipulation import _to_tf_padding, _check_paddle_pad, _to_paddle_padding
label_desc: Use image node_id 9 for calling a global function with example usage: top_k() and returns: topk_res