class_docstr: Tests ActionDistribution classes.
code: def test_beta(self):
      input_space = Box(-2.0, 1.0, shape=(2000, 10))
      input_space.seed(42)
      low, high = -1.0, 2.0
      plain_beta_value_space = Box(0.0, 1.0, shape=(2000, 5))
      plain_beta_value_space.seed(42)
  
      for fw, sess in framework_iterator(session=True):
          cls = TorchBeta if fw == "torch" else Beta
          inputs = input_space.sample()
          beta_distribution = cls(inputs, {}, low=low, high=high)
  
          inputs = beta_distribution.inputs
          if sess:
              inputs = sess.run(inputs)
          else:
              inputs = inputs.numpy()
          alpha, beta_ = np.split(inputs, 2, axis=-1)
  
          # Mean for a Beta distribution: 1 / [1 + (beta/alpha)]
          expected = (1.0 / (1.0 + beta_ / alpha)) * (high - low) + low
          # Sample n times, expect always mean value (deterministic draw).
          out = beta_distribution.deterministic_sample()
          check(out, expected, rtol=0.01)
  
          # Batch of size=n and non-deterministic -> expect roughly the mean.
          values = beta_distribution.sample()
          if sess:
              values = sess.run(values)
          else:
              values = values.numpy()
          self.assertTrue(np.max(values) <= high)
          self.assertTrue(np.min(values) >= low)
  
          check(np.mean(values), expected.mean(), decimals=1)
  
          # Test log-likelihood outputs (against scipy).
          inputs = input_space.sample()
          beta_distribution = cls(inputs, {}, low=low, high=high)
          inputs = beta_distribution.inputs
          if sess:
              inputs = sess.run(inputs)
          else:
              inputs = inputs.numpy()
          alpha, beta_ = np.split(inputs, 2, axis=-1)
  
          values = plain_beta_value_space.sample()
          values_scaled = values * (high - low) + low
          if fw == "torch":
              values_scaled = torch.Tensor(values_scaled)
          print(values_scaled)
          out = beta_distribution.logp(values_scaled)
          check(
              out,
              np.sum(np.log(beta.pdf(values, alpha, beta_)), -1),
              rtol=0.01,
          )
  
imports: from functools import partial
  from gymnasium.spaces import Box, Dict, Tuple
  import numpy
  from scipy.stats import beta, norm
  import tree
  import unittest
  from ray.rllib.models.tf.tf_action_dist import Beta, Categorical, DiagGaussian, GumbelSoftmax, MultiActionDistribution, MultiCategorical, SquashedGaussian
  from ray.rllib.models.torch.torch_action_dist import TorchBeta, TorchCategorical, TorchDiagGaussian, TorchMultiActionDistribution, TorchMultiCategorical, TorchSquashedGaussian
  from ray.rllib.utils.framework import try_import_tf, try_import_torch
  from ray.rllib.utils.numpy import MIN_LOG_NN_OUTPUT, MAX_LOG_NN_OUTPUT, softmax, SMALL_NUMBER, LARGE_INTEGER
  from ray.rllib.utils.test_utils import check, framework_iterator
label_desc: Use image node_id 7 for calling the TestActionDistributions obj's underlying member method code with example usage: obj.test_beta() without return types