code: def reduce_scatter_tensor(
      self: torch.Tensor,
      reduceOp: str,
      scatter_dim: int,
      group: RANK_TYPES,
      tag: str = "",
  ):
      """
      Reduces the tensor data across all machines in such a way that all get
      the final result, then scatter the results to corresponding ranks.
  
  
      The input tensor is left unmodified.
      Group can be one of:
          List[int]: ranks participating in the collective.
          List[List[int]]: 2D mesh of ranks taking part of this collective in MPMD.
          ProcessGroup: Will perform a collective using the ranks and tag of the PG.
          DeviceMesh: Do a SPMD collective over all ranks of the mesh
          (DeviceMesh, int): Do a MPMD collective over one dimension of the DeviceMesh
      :: N.B. If you pass a PG or a 1D list to perform a MPMD collective, the compiler won't be able to recover
      that information and perform collective algebraic optimization. Use other forms of input for that.
      """
      tag, rankset, group_size = _expand_group(group, tag)
      assert (
          self.size(scatter_dim) % group_size == 0
      ), f"input dimension 0 ({self.size(0)} must be a multiple of group_size {group_size}"
      if scatter_dim != 0:
          tensor_list = torch.chunk(self, group_size, dim=scatter_dim)
          self = torch.cat(tensor_list)
  
      tensor = torch.ops.c10d_functional.reduce_scatter_tensor(self, reduceOp, tag, rankset, group_size)  # type: ignore[attr-defined]
      res = _maybe_wrap_tensor(tensor)
      return res
  
imports: import sys
  import warnings
  from typing import cast, List, Optional, Tuple, TYPE_CHECKING, Union
  import torch
  import torch.distributed
  import torch.distributed.distributed_c10d
  from torch._custom_ops import impl_abstract
  from torch.distributed.device_mesh import DeviceMesh
  from torch.fx.experimental.proxy_tensor import get_innermost_proxy_mode
  from .None import _functional_collectives_impl
  from ._functional_collectives_impl import _register_tensor_wrapper
  from torch.distributed.distributed_c10d import all_gather_into_tensor, all_reduce, reduce_scatter_tensor
label_desc: Use image node_id 5 for calling a global function with example usage: reduce_scatter_tensor(reduceOp, scatter_dim, group, tag) and returns: res