code: def iter_discrete_traces(graph_type, fn, *args, **kwargs):
      """
      Iterate over all discrete choices of a stochastic function.
  
      When sampling continuous random variables, this behaves like `fn`.
      When sampling discrete random variables, this iterates over all choices.
  
      This yields traces scaled by the probability of the discrete choices made
      in the `trace`.
  
      :param str graph_type: The type of the graph, e.g. "flat" or "dense".
      :param callable fn: A stochastic function.
      :returns: An iterator over traces pairs.
      """
      queue = LifoQueue()
      queue.put(Trace())
      traced_fn = poutine.trace(
          poutine.queue(
              fn,
              queue,
              escape_fn=iter_discrete_escape,
              extend_fn=iter_discrete_extend,
          ),
          graph_type=graph_type,
      )
      while not queue.empty():
          yield traced_fn.get_trace(*args, **kwargs)
  
file_path: pyro/pyro/infer/enum.py
imports: import numbers
  from functools import partial
  from queue import LifoQueue
  from pyro import poutine
  from pyro.infer.util import is_validation_enabled
  from pyro.poutine import Trace
  from pyro.poutine.enum_messenger import enumerate_site
  from pyro.poutine.util import prune_subsample_sites
  from pyro.util import check_model_guide_match, check_site_shape, ignore_jit_warnings
label_desc: Use image node_id 4 for calling a global function with example usage: iter_discrete_traces(graph_type, fn) without return types