code: def _random_poisson_high_rate(
      sample_shape, log_rate, internal_dtype=tf.float64, seed=None
  ):
      """Samples from the Poisson distribution using transformed rejection sampling.
  
      Given a CDF F(x), and G(x), a dominating distribution chosen such that it is
      close to the inverse CDF F^-1(x), compute the following steps:
  
      1) Generate U and V, two independent random variates. Set U = U - 0.5 (this
      step isn't strictly necessary, but is done to make some calculations symmetric
      and convenient. Henceforth, G is defined on [-0.5, 0.5]).
  
      2) If V <= alpha * F'(G(U)) * G'(U), return floor(G(U)), else return to
      step 1. alpha is the acceptance probability of the rejection algorithm.
      The dominating distribution in this case:
        G(u) = (2 * a / (2 - |u|) + b) * u + c
  
      For more details on transformed rejection, see [1].
  
      Args:
        sample_shape: The output sample shape. Must broadcast with `log_rate`.
        log_rate: Floating point tensor, log rate.
        internal_dtype: dtype to use for internal computations.
        seed: PRNG seed; see `tfp.random.sanitize_seed` for details.
  
      Returns:
        Samples from the poisson distribution using transformed rejection.
  
      #### References
  
      [1]: W. Hormann, G. Derflinger, The Transformed Rejection Method For
      Generating Random Variables, An Alternative To The Ratio Of Uniforms Method
      (1994), Manuskript, Institut f. Statistik, Wirtschaftsuniversitat
      """
      rate = tf.math.exp(log_rate)
  
      b = 0.931 + 2.53 * tf.math.exp(0.5 * log_rate)
      a = -0.059 + 0.02483 * b
      inverse_alpha = 1.1239 + 1.1328 / (b - 3.4)
  
      def generate_and_test_samples(seed):
          """Generate and test samples."""
          u_seed, v_seed = samplers.split_seed(seed)
  
          u = samplers.uniform(
              sample_shape, dtype=internal_dtype, seed=u_seed
          )
          u = u - 0.5
          u_shifted = 0.5 - tf.math.abs(u)
  
          v = samplers.uniform(
              sample_shape, dtype=internal_dtype, seed=v_seed
          )
  
          k = tf.math.floor(
              ((2.0 * a) / u_shifted + b) * u + rate + 0.43
          )
  
          good_sample_mask = (u_shifted >= 0.07) & (
              v <= 0.9277 - 3.6224 / (b - 2.0)
          )
  
          s = tf.math.log(
              v * inverse_alpha / (a / tf.math.square(u_shifted) + b)
          )
          t = -rate + k * log_rate - tf.math.lgamma(k + 1)
  
          good_sample_mask = good_sample_mask | (s <= t)
          # Make sure the sample is within bounds.
          good_sample_mask = (
              good_sample_mask
              & (k >= 0)
              & ((u_shifted >= 0.013) | (v <= u_shifted))
          )
          return k, good_sample_mask
  
      samples = brs.batched_las_vegas_algorithm(
          generate_and_test_samples, seed=seed
      )[0]
  
      return samples
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import batched_rejection_sampler
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import implementation_selection
  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 tensor_util
label_desc: Use image node_id 4 for calling a global function with example usage: _random_poisson_high_rate(sample_shape, log_rate, internal_dtype, seed) and returns: samples, k,  good_sample_mask