code: def test_beta(self, seed, shape, alpha, beta, dtype):
      set_random_seed(1337)
      values = random.beta(
          shape=shape, alpha=alpha, beta=beta, seed=seed, dtype=dtype
      )
      self.assertEqual(ops.shape(values), shape)
      self.assertEqual(backend.standardize_dtype(values.dtype), dtype)
      values_np = ops.convert_to_numpy(values)
      self.assertGreaterEqual(np.min(values_np), b=0.0)
      self.assertLessEqual(np.max(values_np), b=1.0)
  
      _alpha_is_an_array = False
      if isinstance(alpha, list):
          alpha = np.array(alpha)
          beta = np.array(beta)
          _alpha_is_an_array = True
  
      # Mean check:
      # For a beta distributed random variable,
      # mean = alpha / (alpha + beta)
      expected_mean = alpha / (alpha + beta)
  
      if _alpha_is_an_array:
          actual_mean = np.mean(values_np, axis=0)
          self.assertAllClose(
              expected_mean.flatten(),
              actual_mean,
              atol=0.005,
              rtol=0.005,
          )
      else:
          actual_mean = np.mean(values_np.flatten())
          self.assertAlmostEqual(expected_mean, actual_mean, decimal=2)
  
      # Variance check:
      # For a beta distributed random variable,
      # variance = (alpha * beta) / ((alpha + beta)^2)(alpha + beta + 1)
      expected_variance = (alpha * beta) / (
          np.square(alpha + beta) * (alpha + beta + 1)
      )
      if _alpha_is_an_array:
          actual_variance = np.var(values_np, axis=0)
          self.assertAllClose(
              expected_variance.flatten(),
              actual_variance,
              atol=0.005,
              rtol=0.005,
          )
      else:
          actual_variance = np.var(values_np.flatten())
          self.assertAlmostEqual(
              expected_variance, actual_variance, decimal=2
          )
  
imports: import numpy
  import pytest
  from absl.testing import parameterized
  import keras
  from keras import backend
  from keras import ops
  from keras import testing
  from keras.random import random
  from keras.random import seed_generator
  from keras.utils.rng_utils import set_random_seed
label_desc: Use image node_id 18 for calling the RandomTest obj's underlying member method code with example usage: obj.test_beta(seed, shape, alpha, beta, dtype) without return types