code: def _enum_strategy_mixture(dist, msg):
      sample_dim_name = "{}__PARTICLES".format(msg["name"])
      sample_inputs = OrderedDict(
          {sample_dim_name: funsor.Bint[msg["infer"]["num_samples"]]}
      )
      plate_names = frozenset(
          f.name for f in msg["cond_indep_stack"] if f.vectorized
      )
      ancestor_names = frozenset(
          k
          for k, v in dist.inputs.items()
          if v.dtype != "real"
          and k != msg["name"]
          and k not in plate_names
      )
      plate_inputs = OrderedDict(
          (k, dist.inputs[k]) for k in plate_names
      )
      # TODO should the ancestor_indices be pyro.sampled?
      ancestor_indices = {
          # TODO make this comprehension less gross
          name: _get_support_value(
              funsor.torch.distributions.CategoricalLogits(
                  # sample different ancestors for each plate slice
                  logits=funsor.Tensor(
                      # TODO avoid use of torch.zeros here in favor of funsor.ops.new_zeros
                      torch.zeros((1,)).expand(
                          tuple(v.dtype for v in plate_inputs.values())
                          + (dist.inputs[name].dtype,)
                      ),
                      plate_inputs,
                  ),
              )(value=name).sample(name, sample_inputs),
              name,
          )
          for name in ancestor_names
      }
      denom = (
          sum([math.log(v.size) for v in sample_inputs.values()], 0)
          if not ancestor_indices
          else math.log(msg["infer"]["num_samples"])
      )
      sampled_dist = dist(**ancestor_indices).sample(
          msg["name"], sample_inputs if not ancestor_indices else None
      )
      sampled_dist -= denom
      return sampled_dist
  
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 8 for calling a global function with example usage: _enum_strategy_mixture(dist, msg) and returns: sampled_dist