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