code: def _send_recv_serialization_object(
      object: Optional[P2PMetadata],
      send_dst: Optional[int],
      recv_src: Optional[int],
      send_group: Optional[ProcessGroup],
      recv_group: Optional[ProcessGroup],
      current_device: Any,
      is_nccl_backend: bool,
  ) -> Optional[P2PMetadata]:
      ops = []
  
      send_object_tensor = None
      if object is not None and send_dst is not None:
          if Version(torch.__version__) >= Version("1.13.0"):
              (
                  send_object_tensor,
                  send_object_size_tensor,
              ) = c10d._object_to_tensor(object, device=current_device)
          else:
              (
                  send_object_tensor,
                  send_object_size_tensor,
              ) = c10d._object_to_tensor(object)
  
          if is_nccl_backend:
              send_object_size_tensor = send_object_size_tensor.to(
                  current_device
              )
              send_object_tensor = send_object_tensor.to(current_device)
  
          _filling_ops_queue(
              send_object_size_tensor,
              dist.isend,
              send_dst,
              ops,
              send_group,
          )
  
      recv_object_size_tensor = None
      if recv_src is not None:
          recv_object_size_tensor = torch.empty(1, dtype=torch.long)
          if is_nccl_backend:
              recv_object_size_tensor = recv_object_size_tensor.to(
                  current_device
              )
          _filling_ops_queue(
              recv_object_size_tensor,
              dist.irecv,
              recv_src,
              ops,
              recv_group,
          )
  
      if len(ops) > 0:
          reqs = dist.batch_isend_irecv(ops)
          for req in reqs:
              req.wait()
  
      # See the comment in `_batch_send_recv_tensor`
      # torch.cuda.synchronize()
  
      ops = []
  
      if send_dst is not None and send_object_tensor is not None:
          _filling_ops_queue(
              send_object_tensor, dist.isend, send_dst, ops, send_group
          )
  
      recv_object_tensor = None
      if recv_src is not None and recv_object_size_tensor is not None:
          recv_object_tensor = torch.empty(
              recv_object_size_tensor.item(), dtype=torch.uint8
          )
          if is_nccl_backend:
              recv_object_tensor = recv_object_tensor.to(current_device)
          _filling_ops_queue(
              recv_object_tensor, dist.irecv, recv_src, ops, recv_group
          )
  
      if len(ops) > 0:
          reqs = dist.batch_isend_irecv(ops)
          for req in reqs:
              req.wait()
  
      # See the comment in `_batch_send_recv_tensor`
      # torch.cuda.synchronize()
  
      if (
          recv_object_tensor is not None
          and recv_object_size_tensor is not None
      ):
          recv_object_tensor = recv_object_tensor.type(torch.uint8)
          if recv_object_tensor.device != torch.device("cpu"):
              recv_object_tensor = recv_object_tensor.cpu()
  
          unpickle_object = _cuda_safe_tensor_to_object(
              recv_object_tensor, recv_object_size_tensor.item()
          )
  
          if (
              isinstance(unpickle_object, torch.Tensor)
              and unpickle_object.device.index
              != torch.cuda.current_device()
          ):
              unpickle_object = unpickle_object.cuda()
  
          return unpickle_object
  
imports: import io
  import pickle
  import re
  from collections import namedtuple
  from typing import Any, Callable, List, Optional, Tuple, Union
  import torch
  import torch.distributed
  from packaging.version import Version
  from torch.distributed import ProcessGroup
  from torch.distributed import distributed_c10d
  from torch.utils._pytree import tree_flatten, tree_unflatten
  from .stage_manager import PipelineStageManager
label_desc: Use image node_id 9 for calling a global function with example usage: _send_recv_serialization_object(object, send_dst, recv_src, send_group, recv_group, current_device, is_nccl_backend) and returns: unpickle_object