code: def hmc_like_proposed_velocity_getter_fn(kernel_results):
      """Getter for `proposed_velocity` so it can be inspected."""
      final_momentum = unnest.get_innermost(
          kernel_results, "final_momentum"
      )
      proposed_state = unnest.get_innermost(
          kernel_results, "proposed_state"
      )
  
      momentum_distribution = unnest.get_innermost(
          kernel_results, "momentum_distribution", default=None
      )
      if momentum_distribution is None:
          proposed_velocity = final_momentum
      else:
          momentum_log_prob = getattr(
              momentum_distribution,
              "_log_prob_unnormalized",
              momentum_distribution.log_prob,
          )
          kinetic_energy_fn = lambda *args: -momentum_log_prob(*args)
          _, proposed_velocity = mcmc_util.maybe_call_fn_and_grads(
              kinetic_energy_fn, final_momentum
          )
      # proposed_velocity has the wrong structure when state is a scalar.
      return tf.nest.pack_sequence_as(
          proposed_state, tf.nest.flatten(proposed_velocity)
      )
  
imports: import collections
  import functools
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import broadcast_util
  from tensorflow_probability.python.internal import distribute_lib
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import unnest
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.mcmc import kernel
  from tensorflow_probability.python.mcmc import simple_step_size_adaptation
  from tensorflow_probability.python.mcmc import transformed_kernel
  from tensorflow_probability.python.mcmc.internal import util
  from tensorflow.python.util import nest
label_desc: Use image node_id 5 for calling a global function with example usage: hmc_like_proposed_velocity_getter_fn(kernel_results) and returns: tf