class_docstr: An autoguide helper to match a group of model sites.
  
  :ivar torch.Size event_shape: The total flattened concatenated shape of all
      matching sample sites in the model.
  :ivar list prototype_sites: A list of all matching sample sites in a
      prototype trace of the model.
  :param EasyGuide guide: An easyguide instance.
  :param list sites: A list of model sites.
docstr: Wrapper around ``pyro.sample()`` to create a single auxiliary sample
  site and then unpack to multiple sample sites for model replay.
  
  :param str guide_name: The name of the auxiliary guide site.
  :param callable fn: A distribution with shape ``self.event_shape``.
  :param dict infer: Optional inference configuration dict.
  :returns: A pair ``(guide_z, model_zs)`` where ``guide_z`` is the
      single concatenated blob and ``model_zs`` is a dict mapping
      site name to constrained model sample.
  :rtype: tuple
docstr_tok: ["Wrapper","around","``","pyro.sample","(",")","``","to","create","a","single","auxiliary","sample","site","and","then","unpack","to","multiple","sample","sites","for","model","replay",".",":","param","str","guide_name",":","The","name","of","the","auxiliary","guide","site",".",":","param","callable","fn",":","A","distribution","with","shape","``","self.event_shape","``",".",":","param","dict","infer",":","Optional","inference","configuration","dict",".",":","returns",":","A","pair","``","(","guide_z",",","model_zs",")","``","where","``","guide_z","``","is","the","single","concatenated","blob","and","``","model_zs","``","is","a","dict","mapping","site","name","to","constrained","model","sample",".",":","rtype",":","tuple"]
code: def sample(self, guide_name, fn, infer=None):
      """
      Wrapper around ``pyro.sample()`` to create a single auxiliary sample
      site and then unpack to multiple sample sites for model replay.
  
      :param str guide_name: The name of the auxiliary guide site.
      :param callable fn: A distribution with shape ``self.event_shape``.
      :param dict infer: Optional inference configuration dict.
      :returns: A pair ``(guide_z, model_zs)`` where ``guide_z`` is the
          single concatenated blob and ``model_zs`` is a dict mapping
          site name to constrained model sample.
      :rtype: tuple
      """
      # Sample a packed tensor.
      if fn.event_shape != self.event_shape:
          raise ValueError(
              "Invalid fn.event_shape for group: expected {}, actual {}".format(
                  tuple(self.event_shape), tuple(fn.event_shape)
              )
          )
      if infer is None:
          infer = {}
      infer["is_auxiliary"] = True
      guide_z = pyro.sample(guide_name, fn, infer=infer)
      common_batch_shape = guide_z.shape[:-1]
  
      model_zs = {}
      pos = 0
      for site in self.prototype_sites:
          name = site["name"]
          fn = site["fn"]
  
          # Extract slice from packed sample.
          size = self._site_sizes[name]
          batch_shape = broadcast_shape(
              common_batch_shape, self._site_batch_shapes[name]
          )
          unconstrained_z = guide_z[..., pos : pos + size]
          unconstrained_z = unconstrained_z.reshape(
              batch_shape + fn.event_shape
          )
          pos += size
  
          # Transform to constrained space.
          transform = biject_to(fn.support)
          z = transform(unconstrained_z)
          log_density = transform.inv.log_abs_det_jacobian(
              z, unconstrained_z
          )
          log_density = sum_rightmost(
              log_density, log_density.dim() - z.dim() + fn.event_dim
          )
          delta_dist = dist.Delta(
              z, log_density=log_density, event_dim=fn.event_dim
          )
  
          # Replay model sample statement.
          with ExitStack() as stack:
              for frame in site["cond_indep_stack"]:
                  plate = self.guide.plate(frame.name)
                  if plate not in runtime._PYRO_STACK:
                      stack.enter_context(plate)
              model_zs[name] = pyro.sample(name, delta_dist)
  
      return guide_z, model_zs
  
imports: import re
  import weakref
  from abc import ABCMeta, abstractmethod
  from contextlib import ExitStack
  import torch
  from torch.distributions import biject_to
  import pyro
  import pyro.distributions
  import pyro.poutine
  import pyro.poutine.runtime
  from pyro.distributions.util import broadcast_shape, sum_rightmost
  from pyro.infer.autoguide.guides import prototype_hide_fn
  from pyro.infer.autoguide.initialization import InitMessenger
  from pyro.nn.module import PyroModule, PyroParam
label_desc: Use image node_id 5 for calling the Group obj's underlying member method code with example usage: obj.sample(guide_name, fn, infer) and returns: guide_z,  model_zs