code: def _hyp2f1_z_near_one(a, b, c, z):
      """ "Compute 2F1(a, b, c, z) when z is near 1."""
      with tf.name_scope("hyp2f1_z_near_one"):
          dtype = dtype_util.common_dtype([a, b, c, z], tf.float32)
          a = tf.convert_to_tensor(a, dtype=dtype)
          b = tf.convert_to_tensor(b, dtype=dtype)
          c = tf.convert_to_tensor(c, dtype=dtype)
          z = tf.convert_to_tensor(z, dtype=dtype)
  
          # When z > 0.5, We can transform z to 1 - z and make use of a hypergeometric
          # identity.
  
          d = c - a - b
  
          # TODO(b/171982819): When tfp.math.log_gamma_difference and tfp.math.lbeta
          # support negative parameters, use them here for greater accuracy.
          log_first_coefficient = (
              tf.math.lgamma(c)
              + tf.math.lgamma(d)
              - tf.math.lgamma(c - a)
              - tf.math.lgamma(c - b)
          )
  
          sign_first_coefficient = (
              _gamma_negative(c)
              ^ _gamma_negative(d)
              ^ _gamma_negative(c - a)
              ^ _gamma_negative(c - b)
          )
          sign_first_coefficient = (
              -2.0 * tf.cast(sign_first_coefficient, dtype) + 1.0
          )
  
          log_second_coefficient = (
              tf.math.xlog1py(d, -z)
              + tf.math.lgamma(c)
              + tf.math.lgamma(-d)
              - tf.math.lgamma(a)
              - tf.math.lgamma(b)
          )
  
          sign_second_coefficient = (
              _gamma_negative(c)
              ^ _gamma_negative(a)
              ^ _gamma_negative(b)
              ^ _gamma_negative(-d)
          )
          sign_second_coefficient = (
              -2.0 * tf.cast(sign_second_coefficient, dtype) + 1.0
          )
  
          first_term = _hyp2f1_internal(a, b, 1 - d, 1 - z)
          second_term = _hyp2f1_internal(c - a, c - b, d + 1.0, 1 - z)
          log_first_term = log_first_coefficient + tf.math.log(
              tf.math.abs(first_term)
          )
          log_second_term = log_second_coefficient + tf.math.log(
              tf.math.abs(second_term)
          )
  
          sign_first_term = sign_first_coefficient * tf.math.sign(
              first_term
          )
          sign_second_term = sign_second_coefficient * tf.math.sign(
              second_term
          )
          log_diff, sign_log_diff = tfp_math.log_sub_exp(
              log_first_term, log_second_term, return_sign=True
          )
          sign = tf.where(
              tf.math.equal(sign_first_term, sign_second_term),
              sign_first_term,
              sign_first_term * sign_log_diff,
          )
          log_result = tf.where(
              tf.math.equal(sign_first_term, sign_second_term),
              tfp_math.log_add_exp(log_first_term, log_second_term),
              log_diff,
          )
          return tf.math.exp(log_result) * sign
  
file_path: probability/tensorflow_probability/python/math/hypergeometric.py
imports: import functools
  import numpy
  import tensorflow.compat.v2
  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 8 for calling a global function with example usage: _hyp2f1_z_near_one(a, b, c, z) and returns: unknown