code: def _uniform_correlation_like_matrix(
      num_rows, batch_shape, dtype, seed
  ):
      """Returns a uniformly random `Tensor` of "correlation-like" matrices.
  
      A "correlation-like" matrix 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.
  
      Args:
        num_rows: Python `int` dimension of the correlation-like matrices.
        batch_shape: `Tensor` or Python `tuple` of `int` shape of the
          batch to return.
        dtype: `dtype` of the `Tensor` to return.
        seed: PRNG seed; see `tfp.random.sanitize_seed` for details.
  
      Returns:
        matrices: A `Tensor` of shape `batch_shape + [num_rows, num_rows]`
          and dtype `dtype`.  Each entry is in [-1, 1], and each matrix
          along the bottom two dimensions is symmetric and has 1s on the
          main diagonal.
      """
      num_entries = num_rows * (num_rows + 1) // 2
      ones = tf.ones(shape=[num_entries], dtype=dtype)
      # It seems wasteful to generate random values for the diagonal since
      # I am going to throw them away, but `fill_triangular` fills the
      # diagonal, so I probably need them.
      # It's not impossible that it would be more efficient to just fill
      # the whole matrix with random values instead of messing with
      # `fill_triangular`.  Then would need to filter almost half out with
      # `matrix_band_part`.
      unifs = uniform.Uniform(-ones, ones).sample(
          batch_shape, seed=seed
      )
      tril = fill_triangular(unifs)
      symmetric = tril + tf.linalg.matrix_transpose(tril)
      diagonal_ones = tf.ones(
          prefer_static.pad(
              batch_shape, paddings=[[0, 1]], constant_values=num_rows
          ),
          dtype=dtype,
      )
      return tf.linalg.set_diag(symmetric, diagonal_ones)
  
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 3 for calling a global function with example usage: _uniform_correlation_like_matrix(num_rows, batch_shape, dtype, seed) and returns: tf