code: def _correl_pvalue(r, n, k=0, alternative="two-sided"):
      """Compute the p-value of a correlation coefficient.
  
      https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.pearsonr.html
      https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#Using_the_exact_distribution
  
      See also scipy.stats._ttest_finish
  
      Parameters
      ----------
      r : float
          Correlation coefficient.
      n : int
          Sample size
      k : int
          Number of covariates for (semi)-partial correlation.
      alternative : string
          Tail of the test.
  
      Returns
      -------
      pval : float
          p-value.
  
      Notes
      -----
      This uses the same approach as :py:func:`scipy.stats.pearsonr` to calculate
      the p-value (i.e. using a beta distribution)
      """
      from scipy.stats import t
  
      assert alternative in [
          "two-sided",
          "greater",
          "less",
      ], "Alternative must be one of 'two-sided' (default), 'greater' or 'less'."
  
      # Method 1: using a student T distribution
      dof = n - k - 2
      tval = r * np.sqrt(dof / (1 - r**2))
      if alternative == "less":
          pval = t.cdf(tval, dof)
      elif alternative == "greater":
          pval = t.sf(tval, dof)
      elif alternative == "two-sided":
          pval = 2 * t.sf(np.abs(tval), dof)
  
      # Method 2: beta distribution (similar to scipy.stats.pearsonr, faster)
      # from scipy.special import btdtr
      # ab = (n - k) / 2 - 1
      # pval = 2 * btdtr(ab, ab, 0.5 * (1 - abs(np.float64(r))))
      return pval
  
imports: import warnings
  import numpy
  import pandas
  import pandas_flavor
  from scipy.spatial.distance import pdist, squareform
  from scipy.stats import pearsonr, spearmanr, kendalltau
  from pingouin.config import options
  from pingouin.power import power_corr
  from pingouin.multicomp import multicomp
  from pingouin.effsize import compute_esci
  from pingouin.utils import remove_na, _perm_pval, _postprocess_dataframe
  from pingouin.bayesian import bayesfactor_pearson
label_desc: Use image node_id 1 for calling a global function with example usage: _correl_pvalue(r, n, k, alternative) and returns: pval