code: def _independent_log_prob_ratio(p, x, q, y, name=None):
      """Sum-of-diffs log(p(x)/q(y)) for `Independent`s."""
      with tf.name_scope(name or "independent_log_prob_ratio"):
          checks = []
          if p.validate_args or q.validate_args:
              checks.append(
                  tf.debugging.assert_equal(
                      p.reinterpreted_batch_ndims,
                      q.reinterpreted_batch_ndims,
                  )
              )
          if (
              p._experimental_use_kahan_sum
              or q._experimental_use_kahan_sum
          ):  # pylint: disable=protected-access
              sum_fn = lambda x, axis: generic.reduce_kahan_sum(
                  x, axis
              ).total
          else:
              sum_fn = tf.reduce_sum
          with tf.control_dependencies(checks):
              return sum_fn(
                  log_prob_ratio.log_prob_ratio(
                      p.distribution, x, q.distribution, y
                  ),
                  axis=-1 - ps.range(p.reinterpreted_batch_ndims),
              )
  
imports: import collections
  import numpy
  import tensorflow.compat.v2
  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 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
  from tensorflow.python.util import deprecation
label_desc: Use image node_id 2 for calling a global function with example usage: _independent_log_prob_ratio(p, x, q, y, name) and returns: sum_fn