code: def _continued_fraction_kv(v, z, output_log_space=False):
      """Compute Modified Bessels of Second Kind using Hypergeometric functions.
  
      First define `k_n(z) = (-1)**n U(v + n + 0.5, 2 * v + 1., 2 * z)` where
      `U(a, b, z)` is the confluent hypergeometric function.
  
      We can compute via [1] `K_v(z)` and `K_{v + 1}(z)` via the identities:
  
      `K_v(z) = sqrt(pi) * (2 * z) ** v * exp(-z) * k_0(z)`,
      `K_{v + 1}(z) = K_v(z) * (v + z + 0.5 - k_1(z) / k_0(z)`,
  
      This function aims to compute the ratio `k_1(z) / k_0(z)` via
      a continued fraction, under the assumption |v| < 0.5, and finally
      `K_v(z)` and `K_{v + 1}(z)`.
  
      Args:
        v: Floating-point `Tensor` broadcastable with `z`.
        z: Floating-point `Tensor` broadcastable with `v`.
        output_log_space: `bool`. If `True`, output is in log-space.
          Default value: `False`.
      Returns:
        kv_tuple: `K_v(z)` and `K_{v + 1}(z)`.
  
      #### References
      [1] N. Temme, On the Numerical Evaluation of the Modified Bessel Function
        of the Third Kind. Journal of Computational Physics 19, 1975.
      [2] J. Campbell. On Temme's Algorithm for the Modified Bessel Function
        of the Third Kind. https://dl.acm.org/doi/pdf/10.1145/355921.355928
      [3] Numerical Recipes in C. The Art of Scientific Computing,
        2nd Edition, 1992
      """
      dtype = dtype_util.common_dtype([v, z], tf.float32)
      tol = tf.cast(
          np.finfo(dtype_util.as_numpy_dtype(dtype)).eps, dtype=dtype
      )
      max_iterations = 1000
  
      # Use Steed's algorithm to evaluate the confluent hypergeometric
      # function continued fraction in a numerically stable manner.
      def steeds_algorithm(
          should_stop,
          index,
          partial_numerator,
          partial_denominator,
          denominator_ratio,
          convergent_difference,
          hypergeometric_ratio,
          # Terms for recurrence in 6.7.36 in [3].
          k_0,
          k_1,
          # Intermediate coefficient in 6.7.30 in [3].
          c,
          # Intermediate sum in 6.7.35 in [3].
          q,
          hypergeometric_sum,
      ):
          # The numerator is v**2 - (index - 0.5) ** 2
          partial_numerator = partial_numerator - 2.0 * (index - 1.0)
          c = tf.where(should_stop, c, -c * partial_numerator / index)
          next_k = (k_0 - partial_denominator * k_1) / partial_numerator
          k_0 = tf.where(should_stop, k_0, k_1)
          k_1 = tf.where(should_stop, k_1, next_k)
          q = tf.where(should_stop, q, q + c * next_k)
          partial_denominator = partial_denominator + 2.0
          denominator_ratio = 1.0 / (
              partial_denominator
              + partial_numerator * denominator_ratio
          )
          convergent_difference = tf.where(
              should_stop,
              convergent_difference,
              convergent_difference
              * (partial_denominator * denominator_ratio - 1.0),
          )
          hypergeometric_ratio = tf.where(
              should_stop,
              hypergeometric_ratio,
              hypergeometric_ratio + convergent_difference,
          )
          hypergeometric_sum = tf.where(
              should_stop,
              hypergeometric_sum,
              hypergeometric_sum + q * convergent_difference,
          )
          index = index + 1
          should_stop = (
              tf.math.abs(q * convergent_difference)
              < tf.math.abs(hypergeometric_sum) * tol
          ) | (index > max_iterations)
          return (
              should_stop,
              index,
              partial_numerator,
              partial_denominator,
              denominator_ratio,
              convergent_difference,
              hypergeometric_ratio,
              k_0,
              k_1,
              c,
              q,
              hypergeometric_sum,
          )
  
      initial_numerator = tf.math.square(v) - 0.25
      initial_denominator = 2 * (z + 1.0)
      initial_ratio = 1.0 / initial_denominator + tf.zeros_like(v)
      initial_seq = -initial_numerator + tf.zeros_like(z)
  
      (
          _,
          _,
          _,
          _,
          _,
          _,
          hypergeometric_ratio,
          _,
          _,
          _,
          _,
          hypergeometric_sum,
      ) = tf.while_loop(
          cond=lambda stop, *_: tf.reduce_any(~stop),
          body=steeds_algorithm,
          loop_vars=(
              tf.zeros_like(v + z, dtype=tf.bool),
              tf.cast(2.0, dtype=dtype),
              initial_numerator,
              initial_denominator,
              initial_ratio,
              initial_ratio,
              initial_ratio,
              tf.zeros_like(v + z),
              tf.ones_like(v + z),
              initial_seq,
              initial_seq,
              1 - initial_numerator * initial_ratio,
          ),
      )
  
      log_kve = 0.5 * tf.math.log(np.pi / (2 * z)) - tf.math.log(
          hypergeometric_sum
      )
      log_kvp1e = (
          log_kve
          + tf.math.log1p(
              2 * (v + z + initial_numerator * hypergeometric_ratio)
          )
          - tf.math.log(z)
          - dtype_util.as_numpy_dtype(dtype)(np.log(2.0))
      )
      if output_log_space:
          return log_kve, log_kvp1e
      return tf.math.exp(log_kve), tf.math.exp(log_kvp1e)
  
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 13 for calling a global function with example usage: _continued_fraction_kv(v, z, output_log_space) and returns: tf,  tf, should_stop,  index,  partial_numerator,  partial_denominator,  denominator_ratio,  convergent_difference,  hypergeometric_ratio,  k_0,  k_1,  c,  q,  hypergeometric_sum, log_kve,  log_kvp1e