code: def beta(
      random_state,
      a,
      b,
      size=None,
      chunk_size=None,
      gpu=None,
      dtype=None,
  ):
      r"""
      Draw samples from a Beta distribution.
  
      The Beta distribution is a special case of the Dirichlet distribution,
      and is related to the Gamma distribution.  It has the probability
      distribution function
  
      .. math:: f(x; a,b) = \frac{1}{B(\alpha, \beta)} x^{\alpha - 1}
                                                       (1 - x)^{\beta - 1},
  
      where the normalisation, B, is the beta function,
  
      .. math:: B(\alpha, \beta) = \int_0^1 t^{\alpha - 1}
                                   (1 - t)^{\beta - 1} dt.
  
      It is often seen in Bayesian inference and order statistics.
  
      Parameters
      ----------
      a : float or array_like of floats
          Alpha, non-negative.
      b : float or array_like of floats
          Beta, non-negative.
      size : int or tuple of ints, optional
          Output shape.  If the given shape is, e.g., ``(m, n, k)``, then
          ``m * n * k`` samples are drawn.  If size is ``None`` (default),
          a single value is returned if ``a`` and ``b`` are both scalars.
          Otherwise, ``mt.broadcast(a, b).size`` samples are drawn.
      chunk_size : int or tuple of int or tuple of ints, optional
          Desired chunk size on each dimension
      gpu : bool, optional
          Allocate the tensor on GPU if True, False as default
      dtype : data-type, optional
        Data-type of the returned tensor.
  
      Returns
      -------
      out : Tensor or scalar
          Drawn samples from the parameterized beta distribution.
      """
      if dtype is None:
          dtype = (
              np.random.RandomState()
              .beta(handle_array(a), handle_array(b), size=(0,))
              .dtype
          )
      size = random_state._handle_size(size)
      seed = gen_random_seeds(1, random_state.to_numpy())[0]
      op = TensorRandBeta(seed=seed, size=size, gpu=gpu, dtype=dtype)
      return op(a, b, chunk_size=chunk_size)
  
file_path: mars/mars/tensor/random/beta.py
imports: import numpy
  from ...None import opcodes
  from ...serialization.serializables import AnyField
  from ..utils import gen_random_seeds
  from .core import TensorRandomOperandMixin, handle_array, TensorDistribution
label_desc: Use image node_id 1 for calling a global function with example usage: beta(random_state, a, b, size, chunk_size, gpu, dtype) and returns: op