code: def test_mcmc_helper_target_function_constrained() -> None:
      """Set up priors on the model parameters such that we can
      readily compute their expected values."""
      config = gpflow.config.Config(positive_bijector="exp")
      with gpflow.config.as_context(config):
          data = build_data()
          model = build_model(data)
  
      prior_width = 200.0
  
      hmc_helper = gpflow.optimizers.SamplingHelper(
          model.log_posterior_density, model.trainable_parameters
      )
      target_log_prob_fn = hmc_helper.target_log_prob_fn
  
      # Priors which are set on the constrained space
      expected_log_prior = 0.0
      for param in model.trainable_parameters:
          if param.numpy() < 1e-3:
              # Avoid values which would be pathological for the Exp transform
              param.assign(1.0)
  
          low_value = -100
          high_value = low_value + prior_width
  
          param.prior = Uniform(
              low=np.float64(low_value), high=np.float64(high_value)
          )
          param.prior_on = PriorOn.CONSTRAINED
  
          prior_density_on_constrained = 1 / prior_width
          prior_density_on_unconstrained = (
              prior_density_on_constrained * param.numpy()
          )
  
          expected_log_prior += np.log(prior_density_on_unconstrained)
  
      log_marginal_likelihood = model.log_marginal_likelihood().numpy()
      expected_log_prob = log_marginal_likelihood + expected_log_prior
  
      np.testing.assert_allclose(
          target_log_prob_fn(), expected_log_prob, rtol=1e-6
      )
  
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 5 for calling a global function with example usage: test_mcmc_helper_target_function_constrained() without return types