class_docstr: Structured guide whose conditional distributions are Delta, Normal,
  MultivariateNormal, or by a callable, and whose latent variables can depend
  on each other either linearly (in unconstrained space) or via shearing by a
  callable.
  
  Usage::
  
      def model(data):
          x = pyro.sample("x", dist.LogNormal(0, 1))
          with pyro.plate("plate", len(data)):
              y = pyro.sample("y", dist.Normal(0, 1))
              pyro.sample("z", dist.Normal(y, x), obs=data)
  
      # Either fully automatic...
      guide = AutoStructured(model)
  
      # ...or with specified conditional and dependency types...
      guide = AutoStructured(
          model, conditionals="normal", dependencies="linear"
      )
  
      # ...or with custom dependency structure and distribution types.
      guide = AutoStructured(
          model=model,
          conditionals={"x": "normal", "y": "delta"},
          dependencies={"x": {"y": "linear"}},
      )
  
  Once trained, this guide can be used with
  :class:`~pyro.infer.reparam.structured.StructuredReparam` to precondition a
  model for use in HMC and NUTS inference.
  
  .. note:: If you declare a dependency of a high-dimensional downstream
      variable on a low-dimensional upstream variable, you may want to use
      a lower learning rate for that weight, e.g.::
  
          def optim_config(param_name):
              config = {"lr": 0.01}
              if "deps.my_downstream.my_upstream" in param_name:
                  config["lr"] *= 0.1
              return config
  
          adam = pyro.optim.Adam(optim_config)
  
  :param callable model: A Pyro model.
  :param conditionals: Either a single distribution type or a dict mapping
      each latent variable name to a distribution type. A distribution type
      is either a string in {"delta", "normal", "mvn"} or a callable that
      returns a sample from a zero mean (or approximately centered) noise
      distribution (such callables typically call ``pyro.param()`` and
      ``pyro.sample()`` internally).
  :param dependencies: Dependency type, or a dict mapping each site name to a
      dict mapping its upstream dependencies to dependency types. If only a
      dependecy type is provided, dependency structure will be inferred. A
      dependency type is either the string "linear" or a callable that maps a
      *flattened* upstream perturbation to *flattened* downstream
      perturbation. The string "linear" is equivalent to
      ``nn.Linear(upstream.numel(), downstream.numel(), bias=False)``.
      Dependencies must not contain cycles or self-loops.
  :param callable init_loc_fn: A per-site initialization function.
      See :ref:`autoguide-initialization` section for available functions.
  :param float init_scale: Initial scale for the standard deviation of each
      (unconstrained transformed) latent variable.
  :param callable create_plates: An optional function inputing the same
      ``*args,**kwargs`` as ``model()`` and returning a :class:`pyro.plate`
      or iterable of plates. Plates not returned will be created
      automatically as usual. This is useful for data subsampling.
class_docstr_tok: ["Structured","guide","whose","conditional","distributions","are","Delta",",","Normal",",","MultivariateNormal",",","or","by","a","callable",",","and","whose","latent","variables","can","depend","on","each","other","either","linearly","(","in","unconstrained","space",")","or","via","shearing","by","a","callable",".","Usage",":",":","def","model","(","data",")",":","x","=","pyro.sample","(","``","x","''",",","dist.LogNormal","(","0",",","1",")",")","with","pyro.plate","(","``","plate","''",",","len","(","data",")",")",":","y","=","pyro.sample","(","``","y","''",",","dist.Normal","(","0",",","1",")",")","pyro.sample","(","``","z","''",",","dist.Normal","(","y",",","x",")",",","obs=data",")","#","Either","fully","automatic","...","guide","=","AutoStructured","(","model",")","#","...","or","with","specified","conditional","and","dependency","types","...","guide","=","AutoStructured","(","model",",","conditionals=","''","normal","''",",","dependencies=","''","linear","''",")","#","...","or","with","custom","dependency","structure","and","distribution","types",".","guide","=","AutoStructured","(","model=model",",","conditionals=","{","``","x","''",":","``","normal","''",",","``","y","''",":","``","delta","''","}",",","dependencies=","{","``","x","''",":","{","``","y","''",":","``","linear","''","}","}",",",")","Once","trained",",","this","guide","can","be","used","with",":","class",":","`","~pyro.infer.reparam.structured.StructuredReparam","`","to","precondition","a","model","for","use","in","HMC","and","NUTS","inference",".","..","note",":",":","If","you","declare","a","dependency","of","a","high-dimensional","downstream","variable","on","a","low-dimensional","upstream","variable",",","you","may","want","to","use","a","lower","learning","rate","for","that","weight",",","e.g",".",":",":","def","optim_config","(","param_name",")",":","config","=","{","``","lr","''",":","0.01","}","if","``","deps.my_downstream.my_upstream","''","in","param_name",":","config","[","``","lr","''","]","*","=","0.1","return","config","adam","=","pyro.optim.Adam","(","optim_config",")",":","param","callable","model",":","A","Pyro","model",".",":","param","conditionals",":","Either","a","single","distribution","type","or","a","dict","mapping","each","latent","variable","name","to","a","distribution","type",".","A","distribution","type","is","either","a","string","in","{","``","delta","''",",","``","normal","''",",","``","mvn","''","}","or","a","callable","that","returns","a","sample","from","a","zero","mean","(","or","approximately","centered",")","noise","distribution","(","such","callables","typically","call","``","pyro.param","(",")","``","and","``","pyro.sample","(",")","``","internally",")",".",":","param","dependencies",":","Dependency","type",",","or","a","dict","mapping","each","site","name","to","a","dict","mapping","its","upstream","dependencies","to","dependency","types",".","If","only","a","dependecy","type","is","provided",",","dependency","structure","will","be","inferred",".","A","dependency","type","is","either","the","string","``","linear","''","or","a","callable","that","maps","a","*","flattened","*","upstream","perturbation","to","*","flattened","*","downstream","perturbation",".","The","string","``","linear","''","is","equivalent","to","``","nn.Linear","(","upstream.numel","(",")",",","downstream.numel","(",")",",","bias=False",")","``",".","Dependencies","must","not","contain","cycles","or","self-loops",".",":","param","callable","init_loc_fn",":","A","per-site","initialization","function",".","See",":","ref",":","`","autoguide-initialization","`","section","for","available","functions",".",":","param","float","init_scale",":","Initial","scale","for","the","standard","deviation","of","each","(","unconstrained","transformed",")","latent","variable",".",":","param","callable","create_plates",":","An","optional","function","inputing","the","same","``","*","args",",","*","*","kwargs","``","as","``","model","(",")","``","and","returning","a",":","class",":","`","pyro.plate","`","or","iterable","of","plates",".","Plates","not","returned","will","be","created","automatically","as","usual",".","This","is","useful","for","data","subsampling","."]
code: def forward(self, *args, **kwargs):
      if self.prototype_trace is None:
          self._setup_prototype(*args, **kwargs)
  
      deltas = self.get_deltas()
      plates = self._create_plates(*args, **kwargs)
      result = {}
      for name, site in self._sorted_sites:
          with ExitStack() as stack:
              for frame in site["cond_indep_stack"]:
                  if frame.vectorized:
                      stack.enter_context(plates[frame.name])
              result[name] = pyro.sample(name, deltas[name])
  
      return result
  
imports: from collections import OrderedDict, defaultdict
  from contextlib import ExitStack
  from types import SimpleNamespace
  from typing import Callable, Dict, Optional, Union
  import torch
  from torch.distributions import biject_to
  import pyro
  import pyro.distributions
  import pyro.poutine
  from pyro.distributions import constraints
  from pyro.distributions.util import eye_like, is_identically_zero
  from pyro.infer.inspect import get_dependencies
  from pyro.nn.module import PyroModule, PyroParam
  from .guides import AutoGuide
  from .initialization import InitMessenger, init_to_feasible
  from .utils import deep_getattr, deep_setattr, helpful_support_errors
label_desc: Use image node_id 6 for calling the AutoStructured obj's underlying member method code with example usage: obj.forward() and returns: result