code: def beta(shape, alpha, beta, dtype=None, seed=None):
      dtype = dtype or floatx()
      # since tensorflow doesn't offer a beta distribution function
      # so we'll use the formula U(a,b) = (X(a) / (X(a) + Y(b)),
      # where U(a,b) is a beta-distributed random variable with
      # parameters a and b, and X(a) and Y(b) are gamma-distributed
      # random variables with parameters a and b respectively.
  
      # Additionally, we'll use two different seeds for our two
      # gamma random variables to prevent any unintended
      # dependencies and correlations between the generated values
      # due to the usage of same seed.
      seed_1 = tf_draw_seed(seed)
      # The choice of 12 is totally arbitrary, as we're
      # incrementing the first drawn seed by a CONSTANT to
      # ensure deterministic results.
      seed_2 = seed_1 + 12
  
      alpha = tf.convert_to_tensor(alpha, dtype=dtype)
      beta = tf.convert_to_tensor(beta, dtype=dtype)
  
      # tensorflow's tf.random.stateless_gamma has a bit of unconventional
      # implementation of the stateless_gamma function where it checks the
      # broadcastability of alpha's shape with ONLY the RIGHTMOST dimension of
      # the specified output shape instead of considering the whole.
      # Consequently, it then results in errors for perfectly broadcastable shapes
      # such as for output shape of (2, 3) and alpha shape of (1, 3)
      # So to resolve this, we explicitly broadcast alpha and beta to shape before
      # passing them to the stateless_gamma function.
      if tf.rank(alpha) > 1:
          alpha = tf.broadcast_to(alpha, shape)
      if tf.rank(beta) > 1:
          beta = tf.broadcast_to(beta, shape)
  
      gamma_a = tf.random.stateless_gamma(
          shape=shape, seed=seed_1, alpha=alpha, dtype=dtype
      )
      gamma_b = tf.random.stateless_gamma(
          shape=shape, seed=seed_2, alpha=beta, dtype=dtype
      )
      sample = gamma_a / (gamma_a + gamma_b)
      return sample
  
file_path: keras/keras/backend/tensorflow/random.py
imports: import tensorflow
  from tensorflow.experimental import numpy
  from keras.backend.common import standardize_dtype
  from keras.backend.config import floatx
  from keras.random.seed_generator import SeedGenerator
  from keras.random.seed_generator import draw_seed
  from keras.random.seed_generator import make_default_seed
label_desc: Use image node_id 12 for calling a global function with example usage: beta(shape, alpha, beta, dtype, seed) and returns: sample