docstr: Guide for linear models. No amortisation happens over designs.
  Amortisation over data is taken care of by analytic formulae for
  linear models (heavy use of truth).
  
  :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 float regressor_init: initial value for the regressor matrix used to learn the posterior mean.
  :param float scale_tril_init: initial value for posterior `scale_tril` parameter.
  :param bool use_softplus: whether to transform the regressor by a softplus transform: useful if the
                            regressor should be nonnegative but close to zero.
docstr_tok: ["Guide","for","linear","models",".","No","amortisation","happens","over","designs",".","Amortisation","over","data","is","taken","care","of","by","analytic","formulae","for","linear","models","(","heavy","use","of","truth",")",".",":","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","float","regressor_init",":","initial","value","for","the","regressor","matrix","used","to","learn","the","posterior","mean",".",":","param","float","scale_tril_init",":","initial","value","for","posterior","`","scale_tril","`","parameter",".",":","param","bool","use_softplus",":","whether","to","transform","the","regressor","by","a","softplus","transform",":","useful","if","the","regressor","should","be","nonnegative","but","close","to","zero","."]
code: def __init__(
      self,
      d,
      w_sizes,
      y_sizes,
      regressor_init=0.0,
      scale_tril_init=3.0,
      use_softplus=True,
      **kwargs,
  ):
      """
      Guide for linear models. No amortisation happens over designs.
      Amortisation over data is taken care of by analytic formulae for
      linear models (heavy use of truth).
  
      :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 float regressor_init: initial value for the regressor matrix used to learn the posterior mean.
      :param float scale_tril_init: initial value for posterior `scale_tril` parameter.
      :param bool use_softplus: whether to transform the regressor by a softplus transform: useful if the
                                regressor should be nonnegative but close to zero.
      """
      super().__init__()
      # Represent each parameter group as independent Gaussian
      # Making a weak mean-field assumption
      # To avoid this- combine labels
      if not isinstance(d, (tuple, list, torch.Tensor)):
          d = (d,)
      self.regressor = nn.ParameterDict(
          {
              l: nn.Parameter(
                  regressor_init
                  * torch.ones(*(d + (p, sum(y_sizes.values()))))
              )
              for l, p in w_sizes.items()
          }
      )
      self.scale_tril = nn.ParameterDict(
          {
              l: nn.Parameter(
                  scale_tril_init * lexpand(torch.eye(p), *d)
              )
              for l, p in w_sizes.items()
          }
      )
      self.w_sizes = w_sizes
      self.use_softplus = use_softplus
      self.softplus = nn.Softplus()
  
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 1 to create a new LinearModelPosteriorGuide object from inherited base classes: nn with example: obj = LinearModelPosteriorGuide(d, w_sizes, y_sizes, regressor_init, scale_tril_init, use_softplus)