class_docstr: A wrapper for Pipe to control the entire pipeline from a single process.
  Typical usecase would have rank 0 construct `PipeRPCWrapper` and run the
  training loop as normal, and all other ranks would call
  `torch.distributed.rpc.shutdown()`
  
  To run code on each worker, e.g. to run the optimizer, use `foreach_worker`
class_docstr_tok: ["A","wrapper","for","Pipe","to","control","the","entire","pipeline","from","a","single","process",".","Typical","usecase","would","have","rank","0","construct","`","PipeRPCWrapper","`","and","run","the","training","loop","as","normal",",","and","all","other","ranks","would","call","`","torch.distributed.rpc.shutdown","(",")","`","To","run","code","on","each","worker",",","e.g",".","to","run","the","optimizer",",","use","`","foreach_worker","`"]
code: def _recv_result(
      model: AsyncPipe,
      shapes: SizeOrSizes,
      dtypes: DtypeOrDtypes,
      message: PipeMessage,
  ) -> TensorOrTensors:
      group = get_pipeline_parallel_group()
      set_device_based_on_group(group)
  
      assert model.pipeline
      transport = model.pipeline.transport
  
      if isinstance(shapes, torch.Size):
          message.tensor_shapes = [cast(torch.Size, shapes)]
          message.tensor_dtypes = [cast(torch.dtype, dtypes)]
          message = transport.recv_message_tensors(message)
          return message.tensors[0]
      else:
          message.tensor_shapes = cast(List[torch.Size], shapes)
          message.tensor_dtypes = cast(List[torch.dtype], dtypes)
          message = transport.recv_message_tensors(message)
          return message.tensors
  
imports: from threading import Event, Lock, Thread
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast
  import torch
  from torch import nn
  from torch.distributed import ProcessGroup, rpc
  from torch.distributed.distributed_c10d import _get_global_rank
  from fairscale.nn.model_parallel.initialize import get_pipeline_parallel_group
  from .async_pipe import AsyncPipe
  from .types import EVENT_LOOP_QUEUE, PipeMessage, TensorOrTensors
label_desc: Use image node_id 7 for calling the PipeRPCWrapper obj's underlying member method code with example usage: obj._recv_result(model, shapes, dtypes, message) and returns: message, message