code: def test_mcmc_sampler_integration() -> None:
      data = build_data()
      model = build_model(data)
  
      hmc_helper = gpflow.optimizers.SamplingHelper(
          model.log_posterior_density, model.trainable_parameters
      )
  
      hmc = tfp.mcmc.HamiltonianMonteCarlo(
          target_log_prob_fn=hmc_helper.target_log_prob_fn,
          num_leapfrog_steps=2,
          step_size=0.01,
      )
  
      adaptive_hmc = tfp.mcmc.SimpleStepSizeAdaptation(
          hmc,
          num_adaptation_steps=2,
          target_accept_prob=gpflow.utilities.to_default_float(0.75),
          adaptation_rate=0.1,
      )
  
      num_samples = 5
  
      @tf.function
      def run_chain_fn() -> tfp.mcmc.StatesAndTrace:
          return tfp.mcmc.sample_chain(
              num_results=num_samples,
              num_burnin_steps=2,
              current_state=hmc_helper.current_state,
              kernel=adaptive_hmc,
              trace_fn=lambda _, pkr: pkr.inner_results.is_accepted,
          )
  
      samples, _ = run_chain_fn()
  
      assert len(samples) == len(model.trainable_parameters)
      parameter_samples = hmc_helper.convert_to_constrained_values(
          samples
      )
      assert len(parameter_samples) == len(samples)
  
      for i in range(len(model.trainable_parameters)):
          assert len(samples[i]) == num_samples
          assert hmc_helper.current_state[i].numpy() == samples[i][-1]
          assert (
              hmc_helper._parameters[i].numpy()
              == parameter_samples[i][-1]
          )
  
imports: from typing import Tuple
  import numpy
  import pytest
  import tensorflow
  import tensorflow_probability
  from check_shapes import ShapeChecker, check_shapes
  from tensorflow_probability.python.distributions import Gamma, Uniform
  import gpflow
  from gpflow.base import AnyNDArray, PriorOn
  from gpflow.models import GPR
  from gpflow.utilities import to_default_float
label_desc: Use image node_id 8 for calling a global function with example usage: test_mcmc_sampler_integration() and returns: tfp