class_docstr: A two-stage pipeline, which will run all stages in parallel.
  
  A simple usage:
  ```
      pipeline = Pipeline([
          ("preprocess", preprocess, {}),
          ("inference", model, {}),
      ])
      outputs = pipeline.run(inputs)
  ```
class_docstr_tok: ["A","two-stage","pipeline",",","which","will","run","all","stages","in","parallel",".","A","simple","usage",":","``","`","pipeline","=","Pipeline","(","[","(","``","preprocess","''",",","preprocess",",","{","}",")",",","(","``","inference","''",",","model",",","{","}",")",",","]",")","outputs","=","pipeline.run","(","inputs",")","``","`"]
code: def _stage_wrapper(func: Callable, recv_: mp.Queue, send_: mp.Queue):
      if isinstance(func, nn.Module):
          from bigdl.nano.pytorch import InferenceOptimizer
  
          with InferenceOptimizer.get_context(func):
              while True:
                  idx, inputs = recv_.get()
                  outputs = func(inputs)
                  send_.put((idx, outputs))
      else:
          while True:
              idx, inputs = recv_.get()
              outputs = func(inputs)
              send_.put((idx, outputs))
  
file_path: BigDL/python/nano/src/bigdl/nano/pytorch/inference/pipeline.py
imports: import itertools
  import multiprocessing
  import warnings
  from typing import List, Tuple, Callable
  from bigdl.nano.utils.common import EnvContext
  from bigdl.nano.utils.common import invalidInputError
  from bigdl.nano.utils.common import schedule_workers
  from torch import nn
label_desc: Use image node_id 4 for calling the Pipeline obj's underlying member method code with example usage: obj._stage_wrapper(func, recv_, send_) without return types