code: def forward_log_det_jacobian_ratio(
      p,
      x,
      q,
      y,
      event_ndims,
      p_kwargs=None,
      q_kwargs=None,
  ):
      """Computes `p.fldj(x, ndims) - q.fdlj(y, ndims)`, numerically stably.
  
      `p_kwargs` and `q_kwargs` are passed to the registered `fldj_ratio_fn`. The
      fallback implementation passes them to the `forward_log_det_jacobian` methods
      of `p` and `q`.
  
      Args:
        p: A bijector instance.
        x: A tensor from the preimage of `p.forward`.
        q: A bijector instance of the same type as `p`, with matching shape.
        y: A tensor from the preimage of `q.forward`.
        event_ndims: The number of right-hand dimensions comprising the event shapes
          of `x` and `y`.
        p_kwargs: Keyword args to pass to `p`.
        q_kwargs: Keyword args to pass to `q`.
  
      Returns:
        fldj_ratio: `log ((abs o det o jac p)(x) / (abs o det o jac q)(y))`,
          i.e. in TFP code, `p.forward_log_det_jacobian(x, event_ndims) -
          q.forward_log_det_jacobian(y, event_ndims)`. In some cases
          this will be computed with better than naive numerical precision, e.g. by
          moving differences inside of a sum reduction.
      """
      assert type(p) == type(q) or _is_composite_tensor_equivalent(
          p, q
      )  # pylint: disable=unidiomatic-typecheck
      if p_kwargs is None:
          p_kwargs = {}
      if q_kwargs is None:
          q_kwargs = {}
  
      fldj_ratio_fn = _get_ldj_ratio_fn(
          type(p), registry=_fldj_ratio_registry
      )
      ildj_ratio_fn = _get_ldj_ratio_fn(
          type(p), registry=_ildj_ratio_registry
      )
  
      def inverse_fldj_ratio_fn(
          p, x, q, y, event_ndims, p_kwargs, q_kwargs
      ):
          # p.fldj(x) - q.fldj(y) = q.ildj(q(y)) - p.ildj(p(x))
          return ildj_ratio_fn(
              q,
              q.forward(y),
              p,
              p.forward(x),
              q.forward_event_ndims(event_ndims),
              q_kwargs,
              p_kwargs,
          )
  
      if fldj_ratio_fn is None:
          if ildj_ratio_fn is None:
              fldj_ratio_fn = _default_fldj_ratio_fn
          else:
              fldj_ratio_fn = inverse_fldj_ratio_fn
  
      return fldj_ratio_fn(p, x, q, y, event_ndims, p_kwargs, q_kwargs)
  
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 6 for calling a global function with example usage: forward_log_det_jacobian_ratio(p, x, q, y, event_ndims, p_kwargs, q_kwargs) and returns: fldj_ratio_fn, ildj_ratio_fn