code: def cov2corr(cov):
      
      assert cov.ndim == 2, 'covariance matrix should be 2D array'
      inv_sd = 1 / np.sqrt(np.diag(cov))
      corr = cov * inv_sd[None, :] * inv_sd[:, None]
      return corr
docs: Calculate the correlation matrix based on a
          covariance matrix
  
      Parameters
      ----------
  
      cov: 2D array
  
      Returns
      -------
  
      corr: 2D array
          correlation converted from the covarince matrix