class_docstr: This helper makes it easy to read from variables being set with a prior and
  writes values back to the same variables.
  
  Example::
  
      model = ...  # Create a GPflow model
      hmc_helper = SamplingHelper(model.log_posterior_density, model.trainable_parameters)
  
      target_log_prob_fn = hmc_helper.target_log_prob_fn
      current_state = hmc_helper.current_state
  
      hmc = tfp.mcmc.HamiltonianMonteCarlo(target_log_prob_fn=target_log_prob_fn, ...)
      adaptive_hmc = tfp.mcmc.SimpleStepSizeAdaptation(hmc, ...)
  
      @tf.function
      def run_chain_fn():
          return mcmc.sample_chain(
              num_samples, num_burnin_steps, current_state, kernel=adaptive_hmc)
  
      hmc_samples = run_chain_fn()
      parameter_samples = hmc_helper.convert_to_constrained_values(hmc_samples)
docstr: :param target_log_prob_fn: a callable which returns the log-density of the model
      under the target distribution; needs to implicitly depend on the `parameters`.
      E.g. `model.log_posterior_density`.
  :param parameters: List of :class:`gpflow.Parameter` used as a state of the Markov chain.
      E.g. `model.trainable_parameters`
      Note that each parameter must have been given a prior.
docstr_tok: [":","param","target_log_prob_fn",":","a","callable","which","returns","the","log-density","of","the","model","under","the","target","distribution",";","needs","to","implicitly","depend","on","the","`","parameters","`",".","E.g",".","`","model.log_posterior_density","`",".",":","param","parameters",":","List","of",":","class",":","`","gpflow.Parameter","`","used","as","a","state","of","the","Markov","chain",".","E.g",".","`","model.trainable_parameters","`","Note","that","each","parameter","must","have","been","given","a","prior","."]
code: def __init__(
      self,
      target_log_prob_fn: Callable[[], tf.Tensor],
      parameters: Sequence[Parameter],
  ) -> None:
      """
      :param target_log_prob_fn: a callable which returns the log-density of the model
          under the target distribution; needs to implicitly depend on the `parameters`.
          E.g. `model.log_posterior_density`.
      :param parameters: List of :class:`gpflow.Parameter` used as a state of the Markov chain.
          E.g. `model.trainable_parameters`
          Note that each parameter must have been given a prior.
      """
      if not all(
          isinstance(p, Parameter) and p.prior is not None
          for p in parameters
      ):
          raise ValueError(
              "`parameters` should only contain gpflow.Parameter objects with priors"
          )
  
      self._parameters = parameters
      self._target_log_prob_fn = target_log_prob_fn
      self._variables = [p.unconstrained_variable for p in parameters]
  
file_path: GPflow/gpflow/optimizers/mcmc.py
imports: from typing import Callable, Optional, Sequence, Tuple
  import tensorflow
  from gpflow.base import Parameter
label_desc: Use image node_id 1 to create a new SamplingHelper object  with example: obj = SamplingHelper(target_log_prob_fn, parameters)