class_docstr: This version of :class:`~EnumMessenger` uses :func:`~pyro.contrib.funsor.to_data`
  to allocate a fresh enumeration dim for each discrete sample site.
class_docstr_tok: ["This","version","of",":","class",":","`","~EnumMessenger","`","uses",":","func",":","`","~pyro.contrib.funsor.to_data","`","to","allocate","a","fresh","enumeration","dim","for","each","discrete","sample","site","."]
code: def _pyro_sample(self, msg):
      if (
          msg["done"]
          or msg["is_observed"]
          or msg["infer"].get("enumerate") not in {"flat", "parallel"}
          or isinstance(msg["fn"], _Subsample)
      ):
          return
  
      if "funsor" not in msg:
          msg["funsor"] = {}
  
      unsampled_log_measure = to_funsor(msg["fn"], output=funsor.Real)(
          value=msg["name"]
      )
      msg["funsor"]["log_measure"] = enumerate_site(
          unsampled_log_measure, msg
      )
      msg["funsor"]["value"] = _get_support_value(
          msg["funsor"]["log_measure"],
          msg["name"],
          expand=msg["infer"].get("expand", False),
      )
      msg["value"] = to_data(msg["funsor"]["value"])
      msg["done"] = True
  
imports: import functools
  import math
  from collections import OrderedDict
  import funsor
  import torch
  import pyro.poutine.runtime
  import pyro.poutine.util
  from pyro.contrib.funsor.handlers.named_messenger import NamedMessenger
  from pyro.contrib.funsor.handlers.primitives import to_data, to_funsor
  from pyro.contrib.funsor.handlers.replay_messenger import ReplayMessenger
  from pyro.contrib.funsor.handlers.trace_messenger import TraceMessenger
  from pyro.poutine.escape_messenger import EscapeMessenger
  from pyro.poutine.subsample_messenger import _Subsample
label_desc: Use image node_id 1 for calling the EnumMessenger obj's underlying member method code with example usage: obj._pyro_sample(msg) without return types