code: def test_num_chains(
      num_chains, cpu_count, default_init_params, monkeypatch
  ):
      monkeypatch.setattr(
          torch.multiprocessing, "cpu_count", lambda: cpu_count
      )
      data = torch.tensor([1.0])
      initial_params, _, transforms, _ = initialize_model(
          normal_normal_model, model_args=(data,), num_chains=num_chains
      )
      if default_init_params:
          initial_params = None
      kernel = PriorKernel(normal_normal_model)
      available_cpu = max(1, cpu_count - 1)
      mp_context = "spawn"
      with optional(
          pytest.warns(UserWarning), available_cpu < num_chains
      ):
          mcmc = MCMC(
              kernel,
              num_samples=10,
              warmup_steps=10,
              num_chains=num_chains,
              initial_params=initial_params,
              transforms=transforms,
              mp_context=mp_context,
          )
      mcmc.run(data)
      assert mcmc.num_chains == num_chains
      if mcmc.num_chains == 1 or available_cpu < num_chains:
          assert isinstance(mcmc.sampler, _UnarySampler)
      else:
          assert isinstance(mcmc.sampler, _MultiSampler)
  
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 5 for calling a global function with example usage: test_num_chains(num_chains, cpu_count, default_init_params, monkeypatch) without return types