class_docstr: Laplace approximation for a (G)LM.
  
  :param tuple d: the shape by which to expand the guide parameters, e.g. `(num_batches, num_designs)`.
  :param dict w_sizes: map from variable string names to int, indicating the dimension of each
                       weight vector in the linear model.
  :param str tau_label: the label used for inverse variance parameter sample site, or `None` to indicate a
                        fixed variance.
  :param float init_value: initial value for the posterior mean parameters.
class_docstr_tok: ["Laplace","approximation","for","a","(","G",")","LM",".",":","param","tuple","d",":","the","shape","by","which","to","expand","the","guide","parameters",",","e.g",".","`","(","num_batches",",","num_designs",")","`",".",":","param","dict","w_sizes",":","map","from","variable","string","names","to","int",",","indicating","the","dimension","of","each","weight","vector","in","the","linear","model",".",":","param","str","tau_label",":","the","label","used","for","inverse","variance","parameter","sample","site",",","or","`","None","`","to","indicate","a","fixed","variance",".",":","param","float","init_value",":","initial","value","for","the","posterior","mean","parameters","."]
docstr: Sample the posterior.
  
  :param torch.Tensor design: tensor of possible designs.
  :param list target_labels: list indicating the sample sites that are targets, i.e. for which information gain
                             should be measured.
docstr_tok: ["Sample","the","posterior",".",":","param","torch.Tensor","design",":","tensor","of","possible","designs",".",":","param","list","target_labels",":","list","indicating","the","sample","sites","that","are","targets",",","i.e",".","for","which","information","gain","should","be","measured","."]
code: def forward(self, design, target_labels=None):
      """
      Sample the posterior.
  
      :param torch.Tensor design: tensor of possible designs.
      :param list target_labels: list indicating the sample sites that are targets, i.e. for which information gain
                                 should be measured.
      """
      if target_labels is None:
          target_labels = list(self.means.keys())
  
      pyro.module("laplace_guide", self)
      with ExitStack() as stack:
          for plate in iter_plates_to_shape(design.shape[:-2]):
              stack.enter_context(plate)
  
          if self.training:
              # MAP via Delta guide
              for l in target_labels:
                  w_dist = dist.Delta(self.means[l]).to_event(1)
                  pyro.sample(l, w_dist)
          else:
              # Laplace approximation via MVN with hessian
              for l in target_labels:
                  w_dist = dist.MultivariateNormal(
                      self.means[l], scale_tril=self.scale_trils[l]
                  )
                  pyro.sample(l, w_dist)
  
imports: from contextlib import ExitStack
  import torch
  from torch import nn
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.contrib.util import iter_plates_to_shape, lexpand, rmv, rtril, rvv, tensor_to_dict
  from pyro.ops.linalg import rinverse
label_desc: Use image node_id 4 for calling the LinearModelLaplaceGuide obj's underlying member method code with example usage: obj.forward(design, target_labels) without return types