code: def unique_all(
      x: Union[tf.Tensor, tf.Variable],
      /,
      *,
      axis: Optional[int] = None,
      by_value: bool = True,
  ) -> Tuple[
      Union[tf.Tensor, tf.Variable],
      Union[tf.Tensor, tf.Variable],
      Union[tf.Tensor, tf.Variable],
      Union[tf.Tensor, tf.Variable],
  ]:
      Results = namedtuple(
          "Results",
          ["values", "indices", "inverse_indices", "counts"],
      )
  
      if axis is None:
          x = tf.reshape(x, shape=(-1,))
          axis = 0
  
      values, inverse_indices, counts = tf.raw_ops.UniqueWithCountsV2(
          x=x,
          axis=tf.constant([axis], dtype=tf.int32),
      )
  
      tensor_list = x.numpy().tolist()
      if x.dtype.is_floating and tf.reduce_any(tf.math.is_nan(values)):
          unique_nan = tf.math.is_nan(values)
          nan_index = tf.reshape(tf.where(tf.math.is_nan(x)), [-1])
          non_nan_index = tf.experimental.numpy.array(
              [
                  tensor_list.index(val)
                  for val in values
                  if not tf.math.is_nan(val)
              ]
          )
          indices = tf.experimental.numpy.full(
              fill_value=float("NaN"), shape=values.shape
          ).numpy()
          indices[unique_nan] = nan_index
          indices[~unique_nan] = non_nan_index
      else:
          decimal = tf.range(tf.size(inverse_indices)) / tf.size(
              inverse_indices
          )
          inv_sorted = tf.argsort(
              tf.cast(inverse_indices, dtype=decimal.dtype) + decimal
          ).numpy()
          total_counts = tf.concat(
              [
                  tf.zeros((1,), dtype=counts.dtype),
                  tf.cumsum(counts, axis=0)[:-1],
              ],
              0,
          )
          indices = inv_sorted[total_counts]
  
      if by_value:
          values_ = tf.experimental.numpy.moveaxis(values, axis, 0)
          values_ = tf.reshape(values_, (values_.shape[0], -1))
          sort_idx = tf.stack(
              [
                  i[0]
                  for i in sorted(
                      enumerate(values_), key=lambda x: tuple(x[1])
                  )
              ]
          )
          sort_idx = tf.cast(sort_idx, tf.int32)
          values = tf.gather(values, sort_idx, axis=axis)
          counts = tf.gather(counts, sort_idx)
          indices = tf.gather(indices, sort_idx)
          inv_sort_idx = tf.math.invert_permutation(sort_idx)
          inverse_indices = tf.map_fn(
              lambda y: tf.gather(inv_sort_idx, y), inverse_indices
          )
  
      return Results(
          tf.cast(values, dtype=x.dtype),
          tf.cast(indices, dtype=tf.int64),
          tf.cast(inverse_indices, dtype=tf.int64),
          tf.cast(counts, dtype=tf.int64),
      )
  
file_path: ivy/ivy/functional/backends/tensorflow/set.py
imports: import tensorflow
  from typing import Tuple, Union, Optional
  from collections import namedtuple
  from ivy.func_wrapper import with_unsupported_dtypes
  from .None import backend_version
label_desc: Use image node_id 1 for calling a global function with example usage: unique_all() and returns: Results