code: def send_to_next_pipeline_rank(tensor=None):
      """Send output to the next pipeline stage."""
      if not mpu.is_pipeline_last_stage():
          assert tensor is not None
          send_next_op = torch.distributed.P2POp(
              torch.distributed.isend,
              tensor,
              mpu.get_pipeline_model_parallel_next_rank(),
          )
          reqs = torch.distributed.batch_isend_irecv([send_next_op])
          for req in reqs:
              req.wait()
          # To protect against race condition when using batch_isend_irecv().
          torch.cuda.synchronize()
  
file_path: megatron-lm/megatron/text_generation/communication.py
imports: import torch
  from megatron.core import mpu
label_desc: Use image node_id 2 for calling a global function with example usage: send_to_next_pipeline_rank(tensor) without return types