code: def _get_send_recv_group(src_stage, dest_stage):
      """the group id is always the smaller rank unless its a wrap around"""
  
      stage_id = None
  
      first_stage = 0
      last_stage = _grid.pipe_parallel_size - 1
  
      if (
          src_stage == first_stage
          and dest_stage == last_stage
          or dest_stage == first_stage
          and src_stage == last_stage
      ):
          stage_id = last_stage
      elif src_stage > dest_stage:
          stage_id = dest_stage
      else:
          stage_id = src_stage
      """group_id corresponds to group of [group_id, group_id+1]
       unless group_id is the rank of the last stage
       in which case group_id corresponds to group[group_id-num_stages+1, group_id]
       """
      group_id = _grid.stage_to_global(stage_id=stage_id)
  
      return _groups[group_id]
  
file_path: H2O/h2o_flexgen/benchmark/third_party/DeepSpeed/deepspeed/runtime/pipe/p2p.py
imports: import pickle
  import typing
  import torch
  from deepspeed import comm
  from packaging.version import Version
  from deepspeed.git_version_info import torch_info
label_desc: Use image node_id 9 for calling a global function with example usage: _get_send_recv_group(src_stage, dest_stage) and returns: _groups