code: def testSampleWithLargeCountAndSmallProbs(self):
      total_count = tf.constant(1e6, dtype=tf.float32)
      probs = tf.constant(1e-6, dtype=tf.float32)
      dist = binomial_lib.Binomial(
          total_count=total_count, probs=probs, validate_args=True
      )
      small_probs = self.evaluate(dist.prob([0.0, 1.0, 2.0]))
      # Approximate analytic probabilities for very small counts for this
      # binomial:
      # - p(0) = (1 - 1e-6)**1e6 \approx 1/e
      # - p(1) = p(0) * 1e6 * 1e-6 * 1/(1 - 1e-6)
      #        \approx 1/e * 1/(1 - 1e-6) \approx 1/e
      # - p(2) = p(0) * 1e6**2 * choose(2, 1e6) / (1 - 1e-6)**2
      #        \approx 1/e * 1e6 * 1/(1e6 - 1) * 1/2 * 1/(1 - 1e-6)**2
      #        \approx 1/(2*e)
      expected_probs = [np.exp(-1.0), np.exp(-1.0), np.exp(-1.0) / 2.0]
      self.assertAllClose(small_probs, expected_probs)
      small_log_probs = self.evaluate(dist.log_prob([0.0, 1.0, 2.0]))
      expected_log_probs = [-1.0, -1.0, -1.0 - np.log(2)]
      self.assertAllClose(
          small_log_probs, expected_log_probs, rtol=5e-6
      )
  
      n = 1000
      sample_avg = self.evaluate(
          tf.reduce_mean(dist.sample(n, seed=test_util.test_seed()))
      )
      # `sample_avg` has mean 1 and variance ~1/n.  So `sample_avg` should be
      # within `4.9 / sqrt(n)` of 1 with probability `1 - 1e-6`.
      self.assertAllClose(sample_avg, 1.0, atol=4.9 / np.sqrt(n))
  
imports: import numpy
  from scipy import stats
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import binomial
  from tensorflow_probability.python.internal import implementation_selection
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 25 for calling the BinomialTest obj's underlying member method code with example usage: obj.testSampleWithLargeCountAndSmallProbs() without return types