code: def pearsonr_mat(mat, w=None):
      """Utility function to calculate pearson matrix (row-wise).
  
      Parameters
      ----------
      mat : numpy array of shape (n_samples, n_features)
          Input matrix.
  
      w : numpy array of shape (n_features,)
          Weights.
  
      Returns
      -------
      pear_mat : numpy array of shape (n_samples, n_samples)
          Row-wise pearson score matrix.
  
      """
      mat = check_array(mat)
      n_row = mat.shape[0]
      n_col = mat.shape[1]
      pear_mat = np.full([n_row, n_row], 1).astype(float)
  
      if w is not None:
          for cx in range(n_row):
              for cy in range(cx + 1, n_row):
                  curr_pear = wpearsonr(mat[cx, :], mat[cy, :], w)
                  pear_mat[cx, cy] = curr_pear
                  pear_mat[cy, cx] = curr_pear
      else:
          for cx in range(n_col):
              for cy in range(cx + 1, n_row):
                  curr_pear = pearsonr(mat[cx, :], mat[cy, :])[0]
                  pear_mat[cx, cy] = curr_pear
                  pear_mat[cy, cx] = curr_pear
  
      return pear_mat
  
file_path: pyod/pyod/utils/stat_models.py
imports: from __future__ import division
  from __future__ import print_function
  import numpy
  from numba import njit
  from scipy.stats import pearsonr
  from sklearn.utils.validation import check_array
  from sklearn.utils.validation import check_consistent_length
label_desc: Use image node_id 4 for calling a global function with example usage: pearsonr_mat(mat, w) and returns: pear_mat