class_docstr: The LKJ distribution on correlation matrices.
  
  This is a one-parameter family of distributions on correlation matrices.  The
  probability density is proportional to the determinant raised to the power of
  the parameter: `pdf(X; eta) = Z(eta) * det(X) ** (eta - 1)`, where `Z(eta)` is
  a normalization constant.  The uniform distribution on correlation matrices is
  the special case `eta = 1`.
  
  The distribution is named after Lewandowski, Kurowicka, and Joe, who gave a
  sampler for the distribution in [(Lewandowski, Kurowicka, Joe, 2009)][1].
  
  Note: For better numerical stability, it is recommended that you use
  `CholeskyLKJ` instead.
  
  #### Examples
  
  ```python
  # Initialize a single 3x3 LKJ with concentration parameter 1.5
  dist = tfp.distributions.LKJ(dimension=3, concentration=1.5)
  
  # Evaluate this at a batch of two observations, each in R^{3x3}.
  x = ...  # Shape is [2, 3, 3].
  dist.prob(x)  # Shape is [2].
  
  # Draw 6 LKJ-distributed 3x3 correlation matrices
  ans = dist.sample(sample_shape=[2, 3], seed=42)
  # shape of ans is [2, 3, 3, 3]
  ```
class_docstr_tok: ["The","LKJ","distribution","on","correlation","matrices",".","This","is","a","one-parameter","family","of","distributions","on","correlation","matrices",".","The","probability","density","is","proportional","to","the","determinant","raised","to","the","power","of","the","parameter",":","`","pdf","(","X",";","eta",")","=","Z","(","eta",")","*","det","(","X",")","*","*","(","eta","-","1",")","`",",","where","`","Z","(","eta",")","`","is","a","normalization","constant",".","The","uniform","distribution","on","correlation","matrices","is","the","special","case","`","eta","=","1","`",".","The","distribution","is","named","after","Lewandowski",",","Kurowicka",",","and","Joe",",","who","gave","a","sampler","for","the","distribution","in","[","(","Lewandowski",",","Kurowicka",",","Joe",",","2009",")","]","[","1","]",".","Note",":","For","better","numerical","stability",",","it","is","recommended","that","you","use","`","CholeskyLKJ","`","instead",".","#","#","#","#","Examples","``","`","python","#","Initialize","a","single","3x3","LKJ","with","concentration","parameter","1.5","dist","=","tfp.distributions.LKJ","(","dimension=3",",","concentration=1.5",")","#","Evaluate","this","at","a","batch","of","two","observations",",","each","in","R^","{","3x3","}",".","x","=","...","#","Shape","is","[","2",",","3",",","3","]",".","dist.prob","(","x",")","#","Shape","is","[","2","]",".","#","Draw","6","LKJ-distributed","3x3","correlation","matrices","ans","=","dist.sample","(","sample_shape=","[","2",",","3","]",",","seed=42",")","#","shape","of","ans","is","[","2",",","3",",","3",",","3","]","``","`"]
docstr: Returns the unnormalized log density of an LKJ distribution.
  
  Args:
    x: `float` or `double` `Tensor` of correlation matrices.  The shape of `x`
      must be `B + [D, D]`, where `B` broadcasts with the shape of
      `concentration`.
    concentration: `float` or `double` `Tensor`. The positive concentration
      parameter of the LKJ distributions.
    name: Python `str` name prefixed to Ops created by this function.
  
  Returns:
    log_p: A Tensor of the unnormalized log density of each matrix element of
      `x`, with respect to an LKJ distribution with parameter the
      corresponding element of `concentration`.
docstr_tok: ["Returns","the","unnormalized","log","density","of","an","LKJ","distribution",".","Args",":","x",":","`","float","`","or","`","double","`","`","Tensor","`","of","correlation","matrices",".","The","shape","of","`","x","`","must","be","`","B","+","[","D",",","D","]","`",",","where","`","B","`","broadcasts","with","the","shape","of","`","concentration","`",".","concentration",":","`","float","`","or","`","double","`","`","Tensor","`",".","The","positive","concentration","parameter","of","the","LKJ","distributions",".","name",":","Python","`","str","`","name","prefixed","to","Ops","created","by","this","function",".","Returns",":","log_p",":","A","Tensor","of","the","unnormalized","log","density","of","each","matrix","element","of","`","x","`",",","with","respect","to","an","LKJ","distribution","with","parameter","the","corresponding","element","of","`","concentration","`","."]
code: def _log_unnorm_prob(self, x, concentration, name=None):
      """Returns the unnormalized log density of an LKJ distribution.
  
      Args:
        x: `float` or `double` `Tensor` of correlation matrices.  The shape of `x`
          must be `B + [D, D]`, where `B` broadcasts with the shape of
          `concentration`.
        concentration: `float` or `double` `Tensor`. The positive concentration
          parameter of the LKJ distributions.
        name: Python `str` name prefixed to Ops created by this function.
  
      Returns:
        log_p: A Tensor of the unnormalized log density of each matrix element of
          `x`, with respect to an LKJ distribution with parameter the
          corresponding element of `concentration`.
      """
      with tf.name_scope(name or "log_unnorm_prob_lkj"):
          x = tf.convert_to_tensor(x, name="x")
          # The density is det(matrix) ** (concentration - 1).
          # Computing the determinant with `logdet` is usually fine, since
          # correlation matrices are Hermitian and PSD. But in some cases, for a
          # PSD matrix whose eigenvalues are close to zero, `logdet` raises an error
          # complaining that it is not PSD. The root cause is the computation of the
          # cholesky decomposition in `logdet`. Hence, we use the less efficient but
          # more robust `slogdet` which does not use `cholesky`.
          #
          # An alternative would have been to check allow_nan_stats and use
          #   eigenvalues = tf.linalg.self_adjoint_eigvals(x)
          #   psd_mask = tf.cast(
          #     tf.reduce_min(eigenvalues, axis=-1) >= 0, dtype=x.dtype)
          #   tf.where(psd_mask, answer, float('-inf'))
          # to emit probability 0 for inputs that are not PSD, without ever raising
          # an error. More care must be taken, as due to numerical stability issues,
          # self_adjoint_eigvals can return slightly negative eigenvalues even for
          # a PSD matrix.
          if self.input_output_cholesky:
              logdet = 2.0 * tf.reduce_sum(
                  tf.math.log(tf.linalg.diag_part(x)), axis=[-1]
              )
          else:
              # TODO(b/162937268): Remove the hackaround.
              if (
                  not tf.executing_eagerly()
                  and control_flow_util.GraphOrParentsInXlaContext(
                      tf1.get_default_graph()
                  )
              ):
                  s = tf.linalg.svd(x, compute_uv=False)
                  logdet = tf.math.reduce_sum(tf.math.log(s), -1)
              else:
                  logdet = tf.linalg.slogdet(x).log_abs_determinant
          answer = (concentration - 1.0) * logdet
          return answer
  
imports: import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import bijector
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import cholesky_outer_product
  from tensorflow_probability.python.bijectors import correlation_cholesky
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.distributions import beta
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import parameter_properties
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import reparameterization
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import tensor_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.math import linalg
  from tensorflow_probability.python.math import special
  from tensorflow_probability.python.math.numeric import clip_by_value_preserve_gradient
  from tensorflow_probability.python.random import random_ops
  from tensorflow.python.ops import control_flow_util
label_desc: Use image node_id 10 for calling the LKJ obj's underlying member method code with example usage: obj._log_unnorm_prob(x, concentration, name) and returns: answer