code: def _reduce_ldj_ratio(
      unreduced_ldj_ratio,
      p,
      q,
      input_shape,
      min_event_ndims,
      event_ndims,
  ):
      """Reduces an LDJ ratio computed with event_ndims=min_event_ndims."""
      # pylint: disable=protected-access
      have_parameter_batch_shape = (
          p._parameter_batch_shape is not None
          and q._parameter_batch_shape is not None
      )
      if have_parameter_batch_shape:
          parameter_batch_shape = ps.broadcast_shape(
              p._parameter_batch_shape, q._parameter_batch_shape
          )
      else:
          parameter_batch_shape = None
  
      reduce_shape, assertions = bijector_lib.ldj_reduction_shape(
          input_shape,
          event_ndims=event_ndims,
          min_event_ndims=min_event_ndims,
          parameter_batch_shape=parameter_batch_shape,
          allow_event_shape_broadcasting=not (
              p._parts_interact or q._parts_interact
          ),
          validate_args=p.validate_args or q.validate_args,
      )
  
      sum_fn = getattr(
          p, "_sum_fn", getattr(q, "_sum_fn", tf.reduce_sum)
      )
      with tf.control_dependencies(assertions):
          return bijector_lib.reduce_jacobian_det_over_shape(
              unreduced_ldj_ratio,
              reduce_shape=reduce_shape,
              sum_fn=sum_fn,
          )
  
file_path: probability/tensorflow_probability/python/bijectors/ldj_ratio.py
imports: import inspect
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.internal import prefer_static
label_desc: Use image node_id 1 for calling a global function with example usage: _reduce_ldj_ratio(unreduced_ldj_ratio, p, q, input_shape, min_event_ndims, event_ndims) and returns: bijector_lib