code: def _sample_log_prob_ratio(p, x, q, y, name=None):
      """Implements `log_prob_ratio` for tfd.Sample."""
      with tf.name_scope(name or "sample_log_prob_ratio"):
          checks = []
          if p.validate_args or q.validate_args:
              checks.append(
                  tf.debugging.assert_equal(
                      p.sample_shape, q.sample_shape
                  )
              )
          with tf.control_dependencies(checks):
              # pylint: disable=protected-access
              x, aux = p._prepare_for_underlying(x)
              y, _ = q._prepare_for_underlying(y)
              return p._finish_log_prob(
                  log_prob_ratio.log_prob_ratio(
                      p.distribution, x, q.distribution, y
                  ),
                  aux,
              )
  
imports: import functools
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import log_prob_ratio
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import auto_composite_tensor
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  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 3 for calling a global function with example usage: _sample_log_prob_ratio(p, x, q, y, name) and returns: p