docstr: Returns:
      outputs: Tensor
      handle: Optional[Work], if overlap is True
docstr_tok: ["Returns",":","outputs",":","Tensor","handle",":","Optional","[","Work","]",",","if","overlap","is","True"]
code: def forward(
      ctx: Any,
      inputs: Tensor,
      group: ProcessGroup,
      overlap: bool = False,
  ) -> Tuple[Tensor, Any]:
      """
      Returns:
          outputs: Tensor
          handle: Optional[Work], if overlap is True
      """
      assert ctx is not None or not overlap
  
      if ctx is not None:
          ctx.comm_grp = group
  
      comm_size = dist.get_world_size(group)
      if comm_size == 1:
          return inputs.squeeze(0), None
  
      if not inputs.is_contiguous():
          inputs = inputs.contiguous()
  
      output_shape = inputs.shape[1:]
      outputs = torch.empty(
          output_shape, dtype=inputs.dtype, device=inputs.device
      )
      buffer_list = list(torch.chunk(inputs, comm_size, dim=0))
      if not overlap:
          dist.reduce_scatter(outputs, buffer_list, group=group)
          return outputs, None
      else:
          handle = dist.reduce_scatter(
              outputs, buffer_list, group=group, async_op=True
          )
          return outputs, handle
  
imports: from typing import Any, Optional, Tuple
  import torch
  import torch.distributed
  from torch import Tensor
  from torch.cuda.amp import custom_bwd, custom_fwd
  from torch.distributed import ProcessGroup
label_desc: Use image node_id 1 for calling the ReduceScatter obj's underlying member method code with example usage: obj.forward(ctx, inputs, group, overlap) and returns: inputs,  None, outputs,  None, outputs,  handle