class_docstr: GroupGather performs all gather on each of the local process/ GPU groups.
class_docstr_tok: ["GroupGather","performs","all","gather","on","each","of","the","local","process\/","GPU","groups","."]
docstr: Perform forwarding, gathering the stats across different process/ GPU
  group.
docstr_tok: ["Perform","forwarding",",","gathering","the","stats","across","different","process\/","GPU","group","."]
code: def forward(ctx, input, num_sync_devices, num_groups):
      """
      Perform forwarding, gathering the stats across different process/ GPU
      group.
      """
      ctx.num_sync_devices = num_sync_devices
      ctx.num_groups = num_groups
  
      input_list = [
          torch.zeros_like(input) for k in range(get_local_size())
      ]
      dist.all_gather(
          input_list,
          input,
          async_op=False,
          group=get_local_process_group(),
      )
  
      inputs = torch.stack(input_list, dim=0)
      if num_groups > 1:
          rank = get_local_rank()
          group_idx = rank // num_sync_devices
          inputs = inputs[
              group_idx
              * num_sync_devices : (group_idx + 1)
              * num_sync_devices
          ]
      inputs = torch.sum(inputs, dim=0)
      return inputs
  
file_path: pytorchvideo/pytorchvideo/layers/distributed.py
imports: import torch
  import torch.distributed
  from torch._C._distributed_c10d import ProcessGroup
  from torch.autograd.function import Function
label_desc: Use image node_id 1 for calling the GroupGather obj's underlying member method code with example usage: obj.forward(ctx, input, num_sync_devices, num_groups) and returns: inputs