code: def _bessel_iv_ratio_partial(v, z):
      """Computes the derivative of the ratio elementwise with respect to z.
  
      For shorthand, let `I(v) = I(v, z)`, `R(v) = I(v, z) / I(v - 1, z)`
      ```
      R'(v) = (I'(v)I(v - 1) - I(v)I'(v - 1)) / I(v - 1) ** 2
             = 0.5 * ((I(v - 1) + I(v + 1))I(v - 1) - I(v)(
                  I(v) + I(v - 2))) / I(v - 1) ** 2
             = 0.5 * (1. + I(v + 1) / I(v - 1) - (I(v) / I(v - 1)) ** 2 - (
                  I(v) / I(v - 1)) * (I(v - 2) / I(v - 1)))
             = 0.5 * (1. + R(v + 1) * R(v) - R(v) ** 2 - R(v) / R(v - 1))
             = 0.5 * (1. + R(v) * (R(v + 1) - R(v) - 1. / R(v - 1)))
      ```
      To avoid computing R(v - 1) when v <= 1 (which is not valid),
      we can rewrite `I(v - 2) = 2 (v - 1) / z * I(v - 1) + I(v)`.
      Thus the last term becomes:
      ```
      -1. / R(v - 1) = -I(v - 2) / I(v - 1) = -2 (v - 1) / z - R(v)
      ```
  
      Args:
        v: A Tensor with type `float32` or `float64`.
        z: A Tensor with type `float32` or `float64`.
  
      Returns:
        A Tensor with same shape and dtype as `z`.
      """
      result = _bessel_iv_ratio_custom_gradient(v, z)
      partial_z = 0.5 * (
          1.0
          + result
          * (
              _bessel_iv_ratio_custom_gradient(v + 1.0, z)
              - 2.0 * result
              - 2.0 * (v - 1) / z
          )
      )
      return partial_z
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import custom_gradient
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.math import generic
label_desc: Use image node_id 5 for calling a global function with example usage: _bessel_iv_ratio_partial(v, z) and returns: partial_z