code: def _stdtrit_computation(df, p):
      """Return the inverse of `stdtr(df, t)` with respect to `t`."""
      # This function increases the accuracy of an initial estimate for t by using
      # Taylor series expansion iterations as proposed in [5].
      dtype = dtype_util.common_dtype([df, p], tf.float32)
      numpy_dtype = dtype_util.as_numpy_dtype(dtype)
      zero = numpy_dtype(0.0)
      eps = np.finfo(numpy_dtype).eps
      half = numpy_dtype(0.5)
      one = numpy_dtype(1.0)
  
      df, p = [
          tf.convert_to_tensor(param, dtype=dtype) for param in (df, p)
      ]
      broadcast_shape = functools.reduce(
          ps.broadcast_shape, [ps.shape(df), ps.shape(p)]
      )
      df, p = [
          tf.broadcast_to(param, broadcast_shape) for param in (df, p)
      ]
  
      # max_iterations, use_betaincinv, and tolerance were set by experimentation.
      max_iterations = 3
      if numpy_dtype == np.float32:
          use_betaincinv = df < 2.0
          tolerance = numpy_dtype(8.0) * eps
      else:
          use_betaincinv = df < 1.0
          tolerance = numpy_dtype(4096.0) * eps
  
      adjusted_p = tf.where(p < 0.5, p, one - p)
      initial_candidate = tf.where(
          use_betaincinv,
          # Since _stdtrit_betaincinv is expensive, we pass use_betaincinv to it
          # to save computation.
          _stdtrit_betaincinv(
              df, adjusted_p, numpy_dtype, use_betaincinv
          ),
          _stdtrit_series_expansion(df, adjusted_p, numpy_dtype),
      )
  
      def taylor_expansion_improvement(should_stop, candidate):
          stdtr_grad_t = tf.math.exp(log_prob(candidate, df, zero, one))
          should_stop = should_stop | tf.math.equal(stdtr_grad_t, zero)
  
          first_order_correction = (
              adjusted_p - stdtr(df, candidate)
          ) / stdtr_grad_t
  
          candidate_is_zero = tf.math.equal(candidate, zero)
          safe_inv_candidate = tf.where(
              candidate_is_zero, one, tf.math.reciprocal(candidate)
          )
          second_order_correction = (
              half
              * (df + one)
              * tf.math.square(first_order_correction)
              * safe_inv_candidate
              * tf.math.reciprocal(
                  one + (df * safe_inv_candidate) * safe_inv_candidate
              )
          )
          second_order_correction = tf.where(
              candidate_is_zero, zero, second_order_correction
          )
  
          correction = first_order_correction + second_order_correction
          new_candidate = tf.where(
              should_stop, candidate, candidate + correction
          )
  
          adjusted_tolerance = tf.math.abs(tolerance * new_candidate)
          should_stop = should_stop | (
              tf.math.abs(correction) <= adjusted_tolerance
          )
  
          return should_stop, new_candidate
  
      (_, result) = tf.while_loop(
          cond=lambda stop, _: tf.reduce_any(~stop),
          body=taylor_expansion_improvement,
          loop_vars=(
              ~tf.math.is_finite(initial_candidate),
              initial_candidate,
          ),
          maximum_iterations=max_iterations,
      )
  
      # Handle the case (p >= 0.5).
      result = tf.math.sign(half - p) * result
  
      # Determine if the inputs are out of range (should return NaN output).
      result = tf.where(
          (p <= zero) | (p >= one) | (df <= zero),
          numpy_dtype(np.nan),
          result,
      )
  
      return result
  
imports: import functools
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.distributions import gamma
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import custom_gradient
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import special_math
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.math import generic
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.math import numeric
  from tensorflow_probability.python.math import special
label_desc: Use image node_id 15 for calling a global function with example usage: _stdtrit_computation(df, p) and returns: result, should_stop,  new_candidate