code: def _make_sample_loop_body(
      transition_fn, sample_attr="sample", extract_sample_fn=lambda x: x
  ):
      """Builds the scan loop body to sample from a Markov chain."""
  
      def loop_body(seed_and_state, step):
          seed, previous_result = seed_and_state
          state = extract_sample_fn(
              previous_result
          )  # Maybe strip log_prob.
          current_step_seed, seed = samplers.split_seed(seed, n=2)
          new_result = getattr(
              transition_fn(step - 1, state), sample_attr
          )(seed=current_step_seed)
          return seed, new_result
  
      return loop_body
  
imports: import functools
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import log_prob_ratio
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math import generic
label_desc: Use image node_id 1 for calling a global function with example usage: _make_sample_loop_body(transition_fn, sample_attr, extract_sample_fn) and returns: loop_body, seed,  new_result