code: def _is_valid_send_recv(src_stage, dest_stage):
      first_stage = 0
      last_stage = _grid.pipe_parallel_size - 1
      assert (
          abs(src_stage - dest_stage) == 1
          or (src_stage == first_stage and dest_stage == last_stage)
          or (src_stage == last_stage and dest_stage == first_stage)
      ), "Functionality currently limited to send and receive between adjacent ranks only"
  
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 3 for calling a global function with example usage: _is_valid_send_recv(src_stage, dest_stage) without return types