code: def _hyp2f1_taylor_series(a, b, c, z):
      """Compute Hyp2F1(a, b, c, z) via the Taylor Series expansion."""
      with tf.name_scope("hyp2f1_taylor_series"):
          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)
          np_finfo = np.finfo(dtype_util.as_numpy_dtype(dtype))
          tolerance = tf.cast(np_finfo.resolution, dtype=dtype)
  
          broadcast_shape = functools.reduce(
              ps.broadcast_shape, [ps.shape(x) for x in [a, b, c, z]]
          )
  
          def taylor_series(
              should_stop,
              index,
              term,
              taylor_sum,
              previous_term,
              previous_taylor_sum,
              two_before_taylor_sum,
          ):
              new_term = (
                  term
                  * (a + index)
                  * (b + index)
                  * z
                  / ((c + index) * (index + 1.0))
              )
              new_term = tf.where(should_stop, term, new_term)
              new_taylor_sum = tf.where(
                  should_stop, taylor_sum, taylor_sum + new_term
              )
  
              # When a or be is near a negative integer n, it's possibly the term is
              # small because we are computing (a + n) * (b + n) in the numerator.
              # Checking that three consecutive terms are small compared their
              # corresponding sum will let us avoid this error.
              should_stop = (
                  (
                      tf.math.abs(new_term)
                      < tolerance * tf.math.abs(taylor_sum)
                  )
                  & (
                      tf.math.abs(term)
                      < tolerance * tf.math.abs(previous_taylor_sum)
                  )
                  & (
                      tf.math.abs(previous_term)
                      < tolerance * tf.math.abs(two_before_taylor_sum)
                  )
              )
              return (
                  tf.logical_or(should_stop, index > 2000.0),
                  index + 1.0,
                  new_term,
                  new_taylor_sum,
                  term,
                  taylor_sum,
                  previous_taylor_sum,
              )
  
          (_, _, _, taylor_sum, _, _, _) = tf.while_loop(
              cond=lambda stop, *_: tf.reduce_any(~stop),
              body=taylor_series,
              loop_vars=(
                  tf.zeros(broadcast_shape, dtype=tf.bool),
                  tf.cast(0.0, dtype=dtype),
                  # Only the previous term and taylor sum are used for computation.
                  # The rest are used for checking convergence. We can safely set
                  # these to zero.
                  tf.ones(broadcast_shape, dtype=dtype),
                  tf.ones(broadcast_shape, dtype=dtype),
                  tf.zeros(broadcast_shape, dtype=dtype),
                  tf.zeros(broadcast_shape, dtype=dtype),
                  tf.zeros(broadcast_shape, dtype=dtype),
              ),
          )
          return taylor_sum
  
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 1 for calling a global function with example usage: _hyp2f1_taylor_series(a, b, c, z) and returns: taylor_sum, tf,  unknown,  new_term,  new_taylor_sum,  term,  taylor_sum,  previous_taylor_sum