def _bdtr(k, n, p):
<EOL>ones = tf.ones_like(n - k)<EOL>k_eq_n = tf.equal(k, n)<EOL>safe_dn = tf.where(k_eq_n, ones, n - k)<EOL>dk = tf.math.betainc(a=safe_dn, b=k + <NUM_LIT:1>, x=<NUM_LIT:1> - p)<EOL>return tf.where(k_eq_n, ones, dk)<EOL>
The binomial cumulative distribution function.

    Args:
      k: floating point `Tensor`.
      n: floating point `Tensor`.
      p: floating point `Tensor`.

    Returns:
      `sum_{j=0}^k p^j (1 - p)^(n - j)`.