code: def iter_discrete_extend(trace, site, **ignored):
      values = enumerate_site(site)
      enum_total = values.shape[0]
      with ignore_jit_warnings(
          [
              "Converting a tensor to a Python index",
              ("Iterating over a tensor", RuntimeWarning),
          ]
      ):
          values = iter(values)
      for i, value in enumerate(values):
          extended_site = site.copy()
          extended_site["infer"] = site["infer"].copy()
          extended_site["infer"]["_enum_total"] = enum_total
          extended_site["value"] = value
          extended_trace = trace.copy()
          extended_trace.add_node(site["name"], **extended_site)
          yield extended_trace
  
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 2 for calling a global function with example usage: iter_discrete_extend(trace, site) without return types