docstr: Logic of collection of forward in Chimera.
  Currently, only one input one output model is supported
docstr_tok: ["Logic","of","collection","of","forward","in","Chimera",".","Currently",",","only","one","input","one","output","model","is","supported"]
code: def _collect_forward_result(
      self,
      output_pp_ranks: List[int],
      ret_future: Dict[PyRRef, List[Future]],
  ):
      """Logic of collection of forward in Chimera.
      Currently, only one input one output model is supported
      """
      stage_num = self.stage_num
      forward_result = []
      for pp_rank in output_pp_ranks:
          worker_forward_result = [None] * self.num_microbatches
          for microbatch_id in range(self.num_microbatches):
              offset = (microbatch_id % 2) * stage_num
              ret = ret_future[pp_rank + offset][microbatch_id].wait()
              ret = [ret] if isinstance(ret, torch.Tensor) else ret
              worker_forward_result[microbatch_id] = ret
  
          worker_forward_result = list(zip(*worker_forward_result))
          forward_result.extend(worker_forward_result)
  
      return forward_result
  
imports: import threading
  from typing import Callable, Dict, List
  import torch
  from torch._C._distributed_rpc import PyRRef
  from torch.futures import Future
  from colossalai.legacy.pipeline.pipeline_process_group import ppg
  from colossalai.legacy.pipeline.rpc._pipeline_base import Phase, PipelineEngineBase, UniqueKey, WorkerBase, WorkItem
label_desc: Use image node_id 10 for calling the ChimeraPipelineEngine obj's underlying member method code with example usage: obj._collect_forward_result(output_pp_ranks, ret_future) and returns: forward_result