code: def group_argsort(
      src: Tensor,
      index: Tensor,
      dim: int = 0,
      num_groups: Optional[int] = None,
      descending: bool = False,
      return_consecutive: bool = False,
      stable: bool = False,
  ) -> Tensor:
      r"""Returns the indices that sort the tensor :obj:`src` along a given
      dimension in ascending order by value.
      In contrast to :meth:`torch.argsort`, sorting is performed in groups
      according to the values in :obj:`index`.
  
      Args:
          src (torch.Tensor): The source tensor.
          index (torch.Tensor): The index tensor.
          dim (int, optional): The dimension along which to index.
              (default: :obj:`0`)
          num_groups (int, optional): The number of groups.
              (default: :obj:`None`)
          descending (bool, optional): Controls the sorting order (ascending or
              descending). (default: :obj:`False`)
          return_consecutive (bool, optional): If set to :obj:`True`, will not
              offset the output to start from :obj:`0` for each group.
              (default: :obj:`False`)
          stable (bool, optional): Controls the relative order of equivalent
              elements. (default: :obj:`False`)
  
      Example:
          >>> src = torch.tensor([0, 1, 5, 4, 3, 2, 6, 7, 8])
          >>> index = torch.tensor([0, 0, 1, 1, 1, 1, 2, 2, 2])
          >>> group_argsort(src, index)
          tensor([0, 1, 3, 2, 1, 0, 0, 1, 2])
      """
      # Only implemented under certain conditions for now :(
      assert src.dim() == 1 and index.dim() == 1
      assert dim == 0 or dim == -1
      assert src.numel() == index.numel()
  
      if src.numel() == 0:
          return torch.zeros_like(src)
  
      # Normalize `src` to range [0, 1]:
      src = src - src.min()
      src = src / src.max()
  
      # Compute `grouped_argsort`:
      src = src - 2 * index if descending else src + 2 * index
      if torch_geometric.typing.WITH_PT113:
          perm = src.argsort(descending=descending, stable=stable)
      else:
          perm = src.argsort(descending=descending)
          if stable:
              warnings.warn(
                  "Ignoring option `stable=True` in 'group_argsort' "
                  "since it requires PyTorch >= 1.13.0"
              )
      out = torch.empty_like(index)
      out[perm] = torch.arange(index.numel(), device=index.device)
  
      if return_consecutive:
          return out
  
      # Compute cumulative sum of number of entries with the same index:
      count = scatter(
          torch.ones_like(index),
          index,
          dim=dim,
          dim_size=num_groups,
          reduce="sum",
      )
      ptr = cumsum(count)
  
      return out - ptr[index]
  
file_path: pytorch_geometric/torch_geometric/utils/_scatter.py
imports: from typing import Optional
  import torch
  from torch import Tensor
  import torch_geometric.typing
  from torch_geometric import is_compiling, warnings
  from torch_geometric.typing import torch_scatter
  from torch_geometric.utils.functions import cumsum
label_desc: Use image node_id 3 for calling a global function with example usage: group_argsort(src, index, dim, num_groups, descending, return_consecutive, stable) and returns: unknown, torch, out