class_docstr: Abstract TracePosterior object from which posterior inference algorithms inherit.
  When run, collects a bag of execution traces from the approximate posterior.
  This is designed to be used by other utility classes like `EmpiricalMarginal`,
  that need access to the collected execution traces.
docstr: Computes information criterion of the model. Currently, returns only "Widely
  Applicable/Watanabe-Akaike Information Criterion" (WAIC) and the corresponding
  effective number of parameters.
  
  Reference:
  
  [1] `Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC`,
  Aki Vehtari, Andrew Gelman, and Jonah Gabry
  
  :param bool pointwise: a flag to decide if we want to get a vectorized WAIC or not. When
      ``pointwise=False``, returns the sum.
  :returns: a dictionary containing values of WAIC and its effective number of
      parameters.
  :rtype: :class:`OrderedDict`
docstr_tok: ["Computes","information","criterion","of","the","model",".","Currently",",","returns","only","``","Widely","Applicable\/Watanabe-Akaike","Information","Criterion","''","(","WAIC",")","and","the","corresponding","effective","number","of","parameters",".","Reference",":","[","1","]","`","Practical","Bayesian","model","evaluation","using","leave-one-out","cross-validation","and","WAIC","`",",","Aki","Vehtari",",","Andrew","Gelman",",","and","Jonah","Gabry",":","param","bool","pointwise",":","a","flag","to","decide","if","we","want","to","get","a","vectorized","WAIC","or","not",".","When","``","pointwise=False","``",",","returns","the","sum",".",":","returns",":","a","dictionary","containing","values","of","WAIC","and","its","effective","number","of","parameters",".",":","rtype",":",":","class",":","`","OrderedDict","`"]
code: def information_criterion(self, pointwise=False):
      """
      Computes information criterion of the model. Currently, returns only "Widely
      Applicable/Watanabe-Akaike Information Criterion" (WAIC) and the corresponding
      effective number of parameters.
  
      Reference:
  
      [1] `Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC`,
      Aki Vehtari, Andrew Gelman, and Jonah Gabry
  
      :param bool pointwise: a flag to decide if we want to get a vectorized WAIC or not. When
          ``pointwise=False``, returns the sum.
      :returns: a dictionary containing values of WAIC and its effective number of
          parameters.
      :rtype: :class:`OrderedDict`
      """
      if not self.exec_traces:
          return {}
      obs_node = None
      log_likelihoods = []
      for trace in self.exec_traces:
          obs_nodes = trace.observation_nodes
          if len(obs_nodes) > 1:
              raise ValueError(
                  "Infomation criterion calculation only works for models "
                  "with one observation node."
              )
          if obs_node is None:
              obs_node = obs_nodes[0]
          elif obs_node != obs_nodes[0]:
              raise ValueError(
                  "Observation node has been changed, expected {} but got {}".format(
                      obs_node, obs_nodes[0]
                  )
              )
  
          log_likelihoods.append(
              trace.nodes[obs_node]["fn"].log_prob(
                  trace.nodes[obs_node]["value"]
              )
          )
  
      ll = torch.stack(log_likelihoods, dim=0)
      waic_value, p_waic = waic(
          ll,
          torch.tensor(self.log_weights, device=ll.device),
          pointwise,
      )
      return OrderedDict([("waic", waic_value), ("p_waic", p_waic)])
  
imports: import numbers
  import warnings
  from abc import ABCMeta, abstractmethod
  from collections import OrderedDict, defaultdict
  import torch
  import pyro.poutine
  from pyro.distributions import Categorical, Empirical
  from pyro.ops.stats import waic
  from pyro.poutine.util import site_is_subsample
label_desc: Use image node_id 7 for calling the TracePosterior obj's underlying member method code with example usage: obj.information_criterion(pointwise) and returns: OrderedDict, dict