code: def unique_with_inverse(x):
      x = tf.reshape(x, [-1])
      y, idx, _ = tf.unique_with_counts(x)
      return tf.gather(y, idx)
  
file_path: scenic/scenic/projects/robust_segvit/datasets/segmentation_variants.py
imports: import functools
  from typing import Dict, List, Optional, Tuple
  from absl import logging
  import jax.numpy
  import ml_collections
  from scenic.dataset_lib import dataset_utils
  from scenic.dataset_lib import datasets
  from scenic.projects.robust_segvit.datasets import datasets_info
  from scenic.projects.robust_segvit.datasets import denoise_utils
  from scenic.projects.robust_segvit.datasets.segmentation_datasets import exclude_bad_classes
  from scenic.projects.robust_segvit.datasets.segmentation_datasets import get_class_colors
  from scenic.projects.robust_segvit.datasets.segmentation_datasets import get_class_names
  from scenic.projects.robust_segvit.datasets.segmentation_datasets import get_class_proportions
  from scenic.projects.robust_segvit.datasets.segmentation_datasets import get_post_exclusion_labels
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: unique_with_inverse(x) and returns: tf