code: def pearsonr(X, Y, Z, data, boolean=True, **kwargs):
      r"""
      Computes Pearson correlation coefficient and p-value for testing non-correlation.
      Should be used only on continuous data. In case when :math:`Z != \null` uses
      linear regression and computes pearson coefficient on residuals.
  
      Parameters
      ----------
      X: str
          The first variable for testing the independence condition X \u27C2 Y | Z
  
      Y: str
          The second variable for testing the independence condition X \u27C2 Y | Z
  
      Z: list/array-like
          A list of conditional variable for testing the condition X \u27C2 Y | Z
  
      data: pandas.DataFrame
          The dataset in which to test the indepenedence condition.
  
      boolean: bool
          If boolean=True, an additional argument `significance_level` must
              be specified. If p_value of the test is greater than equal to
              `significance_level`, returns True. Otherwise returns False.
  
          If boolean=False, returns the pearson correlation coefficient and p_value
              of the test.
  
      Returns
      -------
      CI Test results: tuple or bool
          If boolean=True, returns True if p-value >= significance_level, else False. If
          boolean=False, returns a tuple of (Pearson's correlation Coefficient, p-value)
  
      References
      ----------
      [1] https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
      [2] https://en.wikipedia.org/wiki/Partial_correlation#Using_linear_regression
      """
      # Step 1: Test if the inputs are correct
      if not hasattr(Z, "__iter__"):
          raise ValueError(
              f"Variable Z. Expected type: iterable. Got type: {type(Z)}"
          )
      else:
          Z = list(Z)
  
      if not isinstance(data, pd.DataFrame):
          raise ValueError(
              f"Variable data. Expected type: pandas.DataFrame. Got type: {type(data)}"
          )
  
      # Step 2: If Z is empty compute a non-conditional test.
      if len(Z) == 0:
          coef, p_value = stats.pearsonr(data.loc[:, X], data.loc[:, Y])
  
      # Step 3: If Z is non-empty, use linear regression to compute residuals and test independence on it.
      else:
          X_coef = np.linalg.lstsq(
              data.loc[:, Z], data.loc[:, X], rcond=None
          )[0]
          Y_coef = np.linalg.lstsq(
              data.loc[:, Z], data.loc[:, Y], rcond=None
          )[0]
  
          residual_X = data.loc[:, X] - data.loc[:, Z].dot(X_coef)
          residual_Y = data.loc[:, Y] - data.loc[:, Z].dot(Y_coef)
          coef, p_value = stats.pearsonr(residual_X, residual_Y)
  
      if boolean:
          if p_value >= kwargs["significance_level"]:
              return True
          else:
              return False
      else:
          return coef, p_value
  
file_path: pgmpy/pgmpy/estimators/CITests.py
imports: import numpy
  import pandas
  from scipy import stats
  from pgmpy.independencies import IndependenceAssertion
  from pgmpy.global_vars import logger
label_desc: Use image node_id 10 for calling a global function with example usage: pearsonr(X, Y, Z, data, boolean) and returns: coef,  p_value, True, False