code: def _do_sampling(
      *,
      kind,
      proposal_kernel_kwargs,
      dual_averaging_kwargs,
      num_draws,
      num_burnin_steps,
      initial_position,
      initial_running_variance,
      trace_fn,
      bijector,
      return_final_kernel_results,
      seed,
      chain_axis_names,
      shard_axis_names,
  ):
      """Sample from base HMC kernel."""
      kernel = make_windowed_adapt_kernel(
          kind=kind,
          proposal_kernel_kwargs=proposal_kernel_kwargs,
          dual_averaging_kwargs=dual_averaging_kwargs,
          initial_running_variance=initial_running_variance,
          chain_axis_names=chain_axis_names,
          shard_axis_names=shard_axis_names,
      )
      return sample.sample_chain(
          num_draws,
          initial_position,
          kernel=kernel,
          num_burnin_steps=num_burnin_steps,
          # pylint: disable=g-long-lambda
          trace_fn=lambda state, pkr: trace_fn(
              state,
              bijector,
              pkr.step <= dual_averaging_kwargs["num_adaptation_steps"],
              pkr.inner_results.inner_results.inner_results,
          ),
          # pylint: enable=g-long-lambda
          return_final_kernel_results=return_final_kernel_results,
          seed=seed,
      )
  
imports: import collections
  import functools
  import warnings
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import invert
  from tensorflow_probability.python.bijectors import joint_map
  from tensorflow_probability.python.bijectors import reshape
  from tensorflow_probability.python.bijectors import restructure
  from tensorflow_probability.python.experimental.mcmc import diagonal_mass_matrix_adaptation
  from tensorflow_probability.python.experimental.mcmc import initialization
  from tensorflow_probability.python.experimental.mcmc import preconditioned_hmc
  from tensorflow_probability.python.experimental.mcmc import preconditioned_nuts
  from tensorflow_probability.python.experimental.mcmc import preconditioning_utils
  from tensorflow_probability.python.experimental.mcmc import sharded
  from tensorflow_probability.python.experimental.stats import sample_stats
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import unnest
  from tensorflow_probability.python.math import generic
  from tensorflow_probability.python.mcmc import dual_averaging_step_size_adaptation
  from tensorflow_probability.python.mcmc import kernel
  from tensorflow_probability.python.mcmc import sample
  from tensorflow_probability.python.mcmc.internal import util
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.util import nest
label_desc: Use image node_id 10 for calling a global function with example usage: _do_sampling() and returns: sample