code: def waic(input, log_weights=None, pointwise=False, dim=0):
      """
      Computes "Widely Applicable/Watanabe-Akaike Information Criterion" (WAIC) and
      its corresponding effective number of parameters.
  
      Reference:
  
      [1] `WAIC and cross-validation in Stan`,
      Aki Vehtari, Andrew Gelman
  
      :param torch.Tensor input: the input tensor, which is log likelihood of a model.
      :param torch.Tensor log_weights: weights of samples along ``dim``.
      :param int dim: the sample dimension of ``input``.
      :returns tuple: tuple of WAIC and effective number of parameters.
      """
      if log_weights is None:
          log_weights = torch.zeros(
              input.size(dim), dtype=input.dtype, device=input.device
          )
  
      # computes log pointwise predictive density: formula (3) of [1]
      dim = input.dim() + dim if dim < 0 else dim
      weighted_input = input + log_weights.reshape(
          [-1] + (input.dim() - dim - 1) * [1]
      )
      lpd = torch.logsumexp(weighted_input, dim=dim) - torch.logsumexp(
          log_weights, dim=0
      )
  
      # computes the effective number of parameters: formula (6) of [1]
      p_waic = _weighted_variance(input, log_weights, dim)
  
      # computes expected log pointwise predictive density: formula (4) of [1]
      elpd = lpd - p_waic
      waic = -2 * elpd
      return (waic, p_waic) if pointwise else (waic.sum(), p_waic.sum())
  
imports: import math
  import numbers
  import torch
  from torch.fft import irfft, rfft
  from .tensor_utils import next_fast_len
label_desc: Use image node_id 14 for calling a global function with example usage: waic(input, log_weights, pointwise, dim) and returns: unknown