code: def correlation_matrix_volume_rejection_samples(
      det_bounds, dim, sample_shape, dtype, seed
  ):
      """Returns rejection samples from trying to get good correlation matrices.
  
      The proposal being rejected from is the uniform distribution on
      "correlation-like" matrices.  We say a matrix is "correlation-like"
      if it is a symmetric square matrix with all entries between -1 and 1
      (inclusive) and 1s on the main diagonal.  Of these, the ones that
      are positive semi-definite are exactly the correlation matrices.
  
      The rejection algorithm, then, is to sample a `Tensor` of
      `sample_shape` correlation-like matrices of dimensions `dim` by
      `dim`, and check each one for (i) being a correlation matrix (i.e.,
      PSD), and (ii) having determinant at least the corresponding entry
      of `det_bounds`.
  
      Args:
        det_bounds: A `Tensor` of lower bounds on the determinants of
          acceptable matrices.  The shape must broadcast with `sample_shape`.
        dim: A Python `int` dimension of correlation matrices to sample.
        sample_shape: Python `tuple` of `int` shape of the samples to
          compute, excluding the two matrix dimensions.
        dtype: The `dtype` in which to do the computation.
        seed: PRNG seed; see `tfp.random.sanitize_seed` for details.
  
      Returns:
        weights: A `Tensor` of shape `sample_shape`.  Each entry is 0 if the
          corresponding matrix was not a correlation matrix, or had too
          small of a determinant.  Otherwise, the entry is the
          multiplicative inverse of the density of proposing that matrix
          uniformly, i.e., the volume of the set of `dim` by `dim`
          correlation-like matrices.
        volume: The volume of the set of `dim` by `dim` correlation-like
          matrices.
      """
      with tf.name_scope("rejection_sampler"):
          rej_proposals = _uniform_correlation_like_matrix(
              dim, sample_shape, dtype, seed=seed
          )
          rej_proposal_volume = 2.0 ** (dim * (dim - 1) / 2.0)
          # The density of proposing any given point is 1 / rej_proposal_volume;
          # The weight of that point should be scaled by
          # 1 / density = rej_proposal_volume.
          rej_weights = (
              rej_proposal_volume
              * _psd_mask(rej_proposals)
              * _det_large_enough_mask(rej_proposals, det_bounds)
          )
          return rej_weights, rej_proposal_volume
  
file_path: probability/tensorflow_probability/python/distributions/internal/correlation_matrix_volumes_lib.py
imports: import sys
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.internal import empirical_statistical_testing
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.math.linalg import fill_triangular
label_desc: Use image node_id 4 for calling a global function with example usage: correlation_matrix_volume_rejection_samples(det_bounds, dim, sample_shape, dtype, seed) and returns: rej_weights,  rej_proposal_volume