parameters: (x, name='lbeta')
docstring: r"""Computes \\(ln(|Beta(x)|)\\), reducing along the last dimension.
  
    Given one-dimensional `z = [z_0,...,z_{K-1}]`, we define
  
    $$Beta(z) = \prod_j Gamma(z_j) / Gamma(\sum_j z_j)$$
  
    And for `n + 1` dimensional `x` with shape `[N1, ..., Nn, K]`, we define
    $$lbeta(x)[i1, ..., in] = Log(|Beta(x[i1, ..., in, :])|)$$.
  
    In other words, the last dimension is treated as the `z` vector.
  
    Note that if `z = [u, v]`, then
    \\(Beta(z) = int_0^1 t^{u-1} (1 - t)^{v-1} dt\\), which defines the
    traditional bivariate beta function.
  
    If the last dimension is empty, we follow the convention that the sum over
    the empty set is zero, and the product is one.
  
    Args:
      x: A rank `n + 1` `Tensor`, `n >= 0` with type `float`, or `double`.
      name: A name for the operation (optional).
  
    Returns:
      The logarithm of \\(|Beta(x)|\\) reducing along the last dimension.
docstring_summary: r"""Computes \\(ln(|Beta(x)|)\\), reducing along the last dimension.
docstring_tokens: r Computes \\ ( ln ( |Beta ( x ) | ) \\ ) reducing along the last dimension .
function: def lbeta(x, name='lbeta'):
    r"""Computes \\(ln(|Beta(x)|)\\), reducing along the last dimension.
  
    Given one-dimensional `z = [z_0,...,z_{K-1}]`, we define
  
    $$Beta(z) = \prod_j Gamma(z_j) / Gamma(\sum_j z_j)$$
  
    And for `n + 1` dimensional `x` with shape `[N1, ..., Nn, K]`, we define
    $$lbeta(x)[i1, ..., in] = Log(|Beta(x[i1, ..., in, :])|)$$.
  
    In other words, the last dimension is treated as the `z` vector.
  
    Note that if `z = [u, v]`, then
    \\(Beta(z) = int_0^1 t^{u-1} (1 - t)^{v-1} dt\\), which defines the
    traditional bivariate beta function.
  
    If the last dimension is empty, we follow the convention that the sum over
    the empty set is zero, and the product is one.
  
    Args:
      x: A rank `n + 1` `Tensor`, `n >= 0` with type `float`, or `double`.
      name: A name for the operation (optional).
  
    Returns:
      The logarithm of \\(|Beta(x)|\\) reducing along the last dimension.
    """
    # In the event that the last dimension has zero entries, we return -inf.
    # This is consistent with a convention that the sum over the empty set 0, and
    # the product is 1.
    # This is standard.  See https://en.wikipedia.org/wiki/Empty_set.
    with ops.name_scope(name, values=[x]):
      x = ops.convert_to_tensor(x, name='x')
  
      # Note reduce_sum([]) = 0.
      log_prod_gamma_x = math_ops.reduce_sum(
          math_ops.lgamma(x), reduction_indices=[-1])
  
      # Note lgamma(0) = infinity, so if x = []
      # log_gamma_sum_x = lgamma(0) = infinity, and
      # log_prod_gamma_x = lgamma(1) = 0,
      # so result = -infinity
      sum_x = math_ops.reduce_sum(x, axis=[-1])
      log_gamma_sum_x = math_ops.lgamma(sum_x)
      result = log_prod_gamma_x - log_gamma_sum_x
  
      return result
function_tokens: def lbeta ( x , name = 'lbeta' ) : # In the event that the last dimension has zero entries, we return -inf. # This is consistent with a convention that the sum over the empty set 0, and # the product is 1. # This is standard.  See https://en.wikipedia.org/wiki/Empty_set. with ops . name_scope ( name , values = [ x ] ) : x = ops . convert_to_tensor ( x , name = 'x' ) # Note reduce_sum([]) = 0. log_prod_gamma_x = math_ops . reduce_sum ( math_ops . lgamma ( x ) , reduction_indices = [ - 1 ] ) # Note lgamma(0) = infinity, so if x = [] # log_gamma_sum_x = lgamma(0) = infinity, and # log_prod_gamma_x = lgamma(1) = 0, # so result = -infinity sum_x = math_ops . reduce_sum ( x , axis = [ - 1 ] ) log_gamma_sum_x = math_ops . lgamma ( sum_x ) result = log_prod_gamma_x - log_gamma_sum_x return result