class_docstr: Parallel runner class for running MCMC chains in parallel. This uses the
  `torch.multiprocessing` module (itself a light wrapper over the python
  `multiprocessing` module) to spin up parallel workers.
class_docstr_tok: ["Parallel","runner","class","for","running","MCMC","chains","in","parallel",".","This","uses","the","`","torch.multiprocessing","`","module","(","itself","a","light","wrapper","over","the","python","`","multiprocessing","`","module",")","to","spin","up","parallel","workers","."]
code: def run(self, *args, **kwargs):
      # Ignore sigint in worker processes; they will be shut down
      # when the main process terminates.
      sigint_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
      self.init_workers(*args, **kwargs)
      # restore original handler
      signal.signal(signal.SIGINT, sigint_handler)
      active_workers = self.num_chains
      exc_raised = True
      try:
          for w in self.workers:
              w.start()
          while active_workers:
              try:
                  chain_id, val = self.result_queue.get(timeout=5)
              except queue.Empty:
                  continue
              if isinstance(val, Exception):
                  # Exception trace is already logged by worker.
                  raise val
              if val is not None:
                  yield val, chain_id
                  self.events[chain_id].set()
              else:
                  active_workers -= 1
          exc_raised = False
      finally:
          self.terminate(terminate_workers=exc_raised)
  
imports: import copy
  import json
  import logging
  import queue
  import signal
  import threading
  import warnings
  from abc import ABC, abstractmethod
  from collections import OrderedDict
  from typing import Dict
  import torch
  import torch.multiprocessing
  import pyro
  import pyro.poutine
  from pyro.infer.mcmc.hmc import HMC
  from pyro.infer.mcmc.logger import DIAGNOSTIC_MSG, ProgressBar, TqdmHandler, initialize_logger
  from pyro.infer.mcmc.nuts import NUTS
  from pyro.infer.mcmc.util import diagnostics, diagnostics_from_stats, print_summary, select_samples
  from pyro.ops.streaming import CountMeanVarianceStats, StatsOfDict, StreamingStats
  from pyro.util import optional
label_desc: Use image node_id 4 for calling the _MultiSampler obj's underlying member method code with example usage: obj.run() without return types