class_docstr: :param model: probabilistic model defined as a function
  :param guide: guide used for sampling defined as a function
  :param num_samples: number of samples to draw from the guide (default 10)
  
  This method performs posterior inference by importance sampling
  using the guide as the proposal distribution.
  If no guide is provided, it defaults to proposing from the model's prior.
class_docstr_tok: [":","param","model",":","probabilistic","model","defined","as","a","function",":","param","guide",":","guide","used","for","sampling","defined","as","a","function",":","param","num_samples",":","number","of","samples","to","draw","from","the","guide","(","default","10",")","This","method","performs","posterior","inference","by","importance","sampling","using","the","guide","as","the","proposal","distribution",".","If","no","guide","is","provided",",","it","defaults","to","proposing","from","the","model","'s","prior","."]
docstr: Generator of weighted samples from the proposal distribution.
docstr_tok: ["Generator","of","weighted","samples","from","the","proposal","distribution","."]
code: def _traces(self, *args, **kwargs):
      """
      Generator of weighted samples from the proposal distribution.
      """
      for i in range(self.num_samples):
          guide_trace = poutine.trace(self.guide).get_trace(
              *args, **kwargs
          )
          model_trace = poutine.trace(
              poutine.replay(self.model, trace=guide_trace)
          ).get_trace(*args, **kwargs)
          log_weight = (
              model_trace.log_prob_sum() - guide_trace.log_prob_sum()
          )
          yield (model_trace, log_weight)
  
file_path: pyro/pyro/infer/importance.py
imports: import math
  import warnings
  import torch
  import pyro
  import pyro.poutine
  from pyro.ops.stats import fit_generalized_pareto
  from .abstract_infer import TracePosterior
  from .enum import get_importance_trace
label_desc: Use image node_id 2 for calling the Importance obj's underlying member method code with example usage: obj._traces() without return types