code: def test_null_model_with_hook(
      run_mcmc_cls, kernel, model, jit, num_chains
  ):
      num_warmup, num_samples = 10, 10
      initial_params, potential_fn, transforms, _ = initialize_model(
          model, num_chains=num_chains
      )
  
      iters = []
      hook = partial(_hook, iters)
  
      mp_context = "spawn" if "CUDA_TEST" in os.environ else None
  
      kern = kernel(
          potential_fn=potential_fn,
          transforms=transforms,
          jit_compile=jit,
      )
      samples, _ = run_mcmc_cls(
          data=None,
          kernel=kern,
          num_samples=num_samples,
          warmup_steps=num_warmup,
          initial_params=initial_params,
          hook_fn=hook,
          num_chains=num_chains,
          mp_context=mp_context,
      )
      assert samples == {}
      if num_chains == 1:
          expected = [("Warmup", i) for i in range(num_warmup)] + [
              ("Sample", i) for i in range(num_samples)
          ]
          assert iters == expected
  
imports: import os
  from functools import partial
  import pytest
  import torch
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer.mcmc import HMC, NUTS
  from pyro.infer.mcmc.api import MCMC, StreamingMCMC, _MultiSampler, _UnarySampler
  from pyro.infer.mcmc.mcmc_kernel import MCMCKernel
  from pyro.infer.mcmc.util import initialize_model, select_samples
  from pyro.ops.streaming import StackStats, StatsOfDict
  from pyro.util import optional
  from tests.common import assert_close
label_desc: Use image node_id 8 for calling a global function with example usage: test_null_model_with_hook(run_mcmc_cls, kernel, model, jit, num_chains) without return types