code: def test_gamma_poisson(hyperpriors):
      def model(data):
          with pyro.plate("latent_dim", data.shape[1]):
              alpha = (
                  pyro.sample("alpha", dist.HalfCauchy(1.0))
                  if hyperpriors
                  else torch.tensor([1.0, 1.0])
              )
              beta = (
                  pyro.sample("beta", dist.HalfCauchy(1.0))
                  if hyperpriors
                  else torch.tensor([1.0, 1.0])
              )
              gamma_poisson = GammaPoissonPair()
              rate = pyro.sample(
                  "rate", gamma_poisson.latent(alpha, beta)
              )
              with pyro.plate("data", data.shape[0]):
                  pyro.sample(
                      "obs", gamma_poisson.conditional(rate), obs=data
                  )
  
      true_rate = torch.tensor([3.0, 10.0])
      num_samples = 100
      data = dist.Poisson(rate=true_rate).sample(
          sample_shape=(torch.Size((100,)))
      )
      hmc_kernel = NUTS(
          collapse_conjugate(model),
          jit_compile=True,
          ignore_jit_warnings=True,
      )
      mcmc = MCMC(hmc_kernel, num_samples=num_samples, warmup_steps=50)
      mcmc.run(data)
      samples = mcmc.get_samples()
      posterior = posterior_replay(
          model, samples, data, num_samples=num_samples
      )
      assert_equal(posterior["rate"].mean(0), true_rate, prec=0.3)
  
imports: import logging
  import os
  from collections import namedtuple
  import pytest
  import torch
  import pyro
  import pyro.distributions
  import pyro.optim
  import pyro.poutine
  from pyro.contrib.conjugate.infer import BetaBinomialPair, GammaPoissonPair, collapse_conjugate, posterior_replay
  from pyro.infer import SVI, TraceEnum_ELBO
  from pyro.infer.autoguide import AutoDelta
  from pyro.infer.mcmc import MCMC, NUTS, ArrowheadMassMatrix
  from pyro.util import ignore_jit_warnings
  from tests.common import assert_close, assert_equal
  from .test_hmc import GaussianChain, rmse
label_desc: Use image node_id 13 for calling a global function with example usage: test_gamma_poisson(hyperpriors) without return types