code: def vi_eig(
      model,
      design,
      observation_labels,
      target_labels,
      vi_parameters,
      is_parameters,
      y_dist=None,
      eig=True,
      **prior_entropy_kwargs,
  ):
      """.. deprecated:: 0.4.1
          Use `posterior_eig` instead.
  
      Estimates the expected information gain (EIG) using variational inference (VI).
  
      The APE is defined as
  
          :math:`APE(d)=E_{Y\\sim p(y|\\theta, d)}[H(p(\\theta|Y, d))]`
  
      where :math:`H[p(x)]` is the `differential entropy
      <https://en.wikipedia.org/wiki/Differential_entropy>`_.
      The APE is related to expected information gain (EIG) by the equation
  
          :math:`EIG(d)=H[p(\\theta)]-APE(d)`
  
      in particular, minimising the APE is equivalent to maximising EIG.
  
      :param function model: A pyro model accepting `design` as only argument.
      :param torch.Tensor design: Tensor representation of design
      :param list observation_labels: A subset of the sample sites
          present in `model`. These sites are regarded as future observations
          and other sites are regarded as latent variables over which a
          posterior is to be inferred.
      :param list target_labels: A subset of the sample sites over which the posterior
          entropy is to be measured.
      :param dict vi_parameters: Variational inference parameters which should include:
          `optim`: an instance of :class:`pyro.Optim`, `guide`: a guide function
          compatible with `model`, `num_steps`: the number of VI steps to make,
          and `loss`: the loss function to use for VI
      :param dict is_parameters: Importance sampling parameters for the
          marginal distribution of :math:`Y`. May include `num_samples`: the number
          of samples to draw from the marginal.
      :param pyro.distributions.Distribution y_dist: (optional) the distribution
          assumed for the response variable :math:`Y`
      :param bool eig: Whether to compute the EIG or the average posterior entropy (APE). The EIG is given by
          `EIG = prior entropy - APE`. If `True`, the prior entropy will be estimated analytically,
          or by Monte Carlo as appropriate for the `model`. If `False` the APE is returned.
      :param dict prior_entropy_kwargs: parameters for estimating the prior entropy: `num_prior_samples` indicating the
          number of samples for a MC estimate of prior entropy, and `mean_field` indicating if an analytic form for
          a mean-field prior should be tried.
      :return: EIG estimate, optionally includes full optimization history
      :rtype: torch.Tensor
  
      """
  
      warnings.warn(
          "`vi_eig` is deprecated in favour of the amortized version: `posterior_eig`.",
          DeprecationWarning,
      )
  
      if isinstance(observation_labels, str):
          observation_labels = [observation_labels]
      if target_labels is not None and isinstance(target_labels, str):
          target_labels = [target_labels]
  
      ape = _vi_ape(
          model,
          design,
          observation_labels,
          target_labels,
          vi_parameters,
          is_parameters,
          y_dist=y_dist,
      )
      return _eig_from_ape(
          model, design, target_labels, ape, eig, prior_entropy_kwargs
      )
  
imports: import math
  import warnings
  import torch
  import pyro
  from pyro import poutine
  from pyro.contrib.oed.search import Search
  from pyro.contrib.util import lexpand
  from pyro.infer import SVI, EmpiricalMarginal, Importance
  from pyro.infer.autoguide.utils import mean_field_entropy
  from pyro.util import torch_isinf, torch_isnan
label_desc: Use image node_id 4 for calling a global function with example usage: vi_eig(model, design, observation_labels, target_labels, vi_parameters, is_parameters, y_dist, eig) and returns: _eig_from_ape