code: def _posterior_ape(
      model,
      design,
      observation_labels,
      target_labels,
      num_samples,
      num_steps,
      guide,
      optim,
      return_history=False,
      final_design=None,
      final_num_samples=None,
      *args,
      **kwargs,
  ):
      loss = _posterior_loss(
          model,
          guide,
          observation_labels,
          target_labels,
          *args,
          **kwargs,
      )
      return opt_eig_ape_loss(
          design,
          loss,
          num_samples,
          num_steps,
          optim,
          return_history,
          final_design,
          final_num_samples,
      )
  
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 9 for calling a global function with example usage: _posterior_ape(model, design, observation_labels, target_labels, num_samples, num_steps, guide, optim, return_history, final_design, final_num_samples) and returns: opt_eig_ape_loss