code: def remove_duplicates(reducing_tensor: torch.Tensor):
      """Remove duplicates from a tensor.
  
      Args:
          reducing_tensor (torch.Tensor): The tensor to remove duplicates from.
      """
      # reducing tensor has shape (1, N_mc, S, S, S)
      n_mc = reducing_tensor.shape[1]
      indexes = []
      idx_map = {}
      for idx in range(n_mc):
          if len(indexes) == 0:
              indexes.append(idx)
              idx_map[idx] = []
          else:
              idx_tensor = reducing_tensor[:, idx]
              for index in indexes:
                  if (
                      reducing_tensor[:, index] - idx_tensor == 0
                  ).all():
                      idx_map[index].append(idx)
                      break
              else:
                  indexes.append(idx)
                  idx_map[idx] = []
  
      # idx_map = {i: len(v) for i, v in enumerate(idx_map.values())}
      old_idx_to_new_idx_map = {}
      for new_idx, (key, values) in enumerate(idx_map.items()):
          old_idx_to_new_idx_map[key] = new_idx
          for second_idx in values:
              old_idx_to_new_idx_map[second_idx] = new_idx
      return (
          reducing_tensor[:, indexes],
          old_idx_to_new_idx_map,
          idx_map,
          indexes,
      )
  
file_path: nebuly/optimization/open_alpha_tensor/open_alpha_tensor/core/actors/stage.py
imports: from typing import Dict, List
  import torch
  from open_alpha_tensor.core.data.utils import get_scalars, map_action_to_triplet
  from open_alpha_tensor.core.modules.alpha_tensor import AlphaTensorModel
label_desc: Use image node_id 2 for calling a global function with example usage: remove_duplicates(reducing_tensor) and returns: reducing_tensor,  old_idx_to_new_idx_map,  idx_map,  indexes