code: def _is_valid_correlation_matrix(Sigma, tol=1e-6):
      """Check if supplied matrix is a valid correlation matrix
  
      A matrix is a valid correlation matrix if it is positive semidefinite, and
      if all diagonal elements are equal to 1.
  
      Args:
          Sigma: A n x n correlation matrix, or a batch of b correlation matrices
              with shape b x n x n
          tol: The tolerance with which to check unit value of the diagonal elements
  
      Returns:
          True if Sigma is a valid correlation matrix, False otherwise (in batch
              mode, all matrices in the batch need to be valid correlation matrices)
  
      """
      if settings.verbose_linalg.on():
          settings.verbose_linalg.logger.debug(
              f"Running symeig on a matrix of size {Sigma.shape}."
          )
  
      evals = torch.linalg.eigvalsh(Sigma)
      if not torch.all(evals >= -tol):
          return False
      return all(
          torch.all(torch.abs(S.diagonal(dim1=-1, dim2=-2) - 1) < tol)
          for S in Sigma.view(-1, *Sigma.shape[-2:])
      )
  
imports: import torch
  from linear_operator.utils.cholesky import psd_safe_cholesky
  from torch.distributions import constraints, LKJCholesky
  from torch.nn import Module
  from ..None import settings
  from .prior import Prior
label_desc: Use image node_id 2 for calling a global function with example usage: _is_valid_correlation_matrix(Sigma, tol) and returns: all, False