code: def _ildj_ratio_composition(
      p, x, q, y, event_ndims, p_kwargs, q_kwargs
  ):
      """Composition ILDJ ratio."""
      p_bijectors_with_metadata = p._get_bijectors_with_metadata(  # pylint: disable=protected-access
          x, event_ndims, forward=False, **p_kwargs
      )
      q_bijectors_with_metadata = q._get_bijectors_with_metadata(  # pylint: disable=protected-access
          y, event_ndims, forward=False, **q_kwargs
      )
  
      if len(p_bijectors_with_metadata) != len(
          q_bijectors_with_metadata
      ):
          raise ValueError(
              f'Composition "{p.name}" and "{q.name}" have different numbers of '
              f"component bijectors: {len(p_bijectors_with_metadata)} != "
              f"{len(q_bijectors_with_metadata)}."
          )
  
      # We do a running sum for the purpose of dtype inference.
      ldj_ratio_sum = tf.zeros([], dtype=tf.float32)
      assertions = []
  
      for p_bm, q_bm in zip(
          p_bijectors_with_metadata, q_bijectors_with_metadata
      ):
          ldj_ratio = ldj_ratio_lib.inverse_log_det_jacobian_ratio(
              p=p_bm.bijector,
              x=p_bm.x,
              q=q_bm.bijector,
              y=q_bm.x,
              event_ndims=p_bm.x_event_ndims,
              p_kwargs=p_bm.kwargs,
              q_kwargs=q_bm.kwargs,
          )
  
          ldj_ratio = tf.convert_to_tensor(
              ldj_ratio, dtype_hint=ldj_ratio_sum.dtype
          )
  
          if not dtype_util.is_floating(ldj_ratio.dtype):
              raise TypeError(
                  f'Nested bijector "{p_bm.bijector.name}" of Composition "{p.name}" '
                  f'and bijector "{q_bm.bijector.name}" of Composition "{q.name}" '
                  f"returned ILDJ ratio with a non-floating dtype: {ldj_ratio.dtype}"
              )
          ldj_ratio_sum = _max_precision_sum(ldj_ratio_sum, ldj_ratio)
          assertions.extend(p_bm.assertions)
          assertions.extend(q_bm.assertions)
  
      with tf.control_dependencies(assertions):
          return tf.identity(ldj_ratio_sum, name="ildj_ratio")
  
imports: import collections
  import functools
  import sys
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.bijectors import ldj_ratio
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import nest_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.util import nest
label_desc: Use image node_id 8 for calling a global function with example usage: _ildj_ratio_composition(p, x, q, y, event_ndims, p_kwargs, q_kwargs) and returns: tf