code: def _pandas_compute_correlation_matrix(
      data, cluster=False, categorical=False
  ):
      """Correlation matrix of numeric variables.
  
      Args:
          data (DataFrame): The data frame
          cluster (bool): If True, use clustering to reorder similar columns together
          categorical (bool): If True, calculate categorical associations using Cramer's V,
              Correlation Ratio, and Point-biserial coefficient (aka Matthews correlation
              coefficient). All associations (including Pearson correlation) are in the
              range [0, 1].
  
      Raises:
          ValueError: Missing numeric data to compute correlations.
  
      Returns:
          CorrelationWidget
      """
      numeric = data.select_dtypes(["number"])
      categoric = data[
          [col for col in data.columns if col not in numeric.columns]
      ]
  
      has_categoric = categoric.shape[1] > 0
      has_numeric = numeric.shape[1] > 0
  
      if categorical and not has_categoric:
          warnings.warn(
              UserWarning(
                  "Categorical associations were requested, but no categorical features were found. "
                  "Defaulting to Pearson Correlation."
              )
          )
          categorical = False
  
      if categorical:
          if has_numeric:
              association_numeric = np.abs(numeric.corr())
              association_cramers = _cramers_v_matrix(categoric)
              association_cr = _correlation_ratio_matrix(
                  numeric, categoric
              )
  
              association_matrix = pd.concat(
                  [
                      pd.concat(
                          [association_numeric, association_cr], axis=1
                      ),
                      pd.concat(
                          [association_cr.T, association_cramers],
                          axis=1,
                      ),
                  ],
                  axis=0,
              )
          else:
              association_matrix = _cramers_v_matrix(categoric)
  
          association_matrix.fillna(0, inplace=True)
  
          if cluster:
              cluster_matrix = _reorder_by_cluster(association_matrix)
          else:
              association_matrix = _reorder_by_original(
                  association_matrix, data
              )
  
      else:
          if has_numeric:
              association_matrix = numeric.corr()
          else:
              raise ValueError(
                  "No numerical features were found. Could not compute correlation."
              )
  
          association_matrix.fillna(0, inplace=True)
  
          if cluster:
              cluster_matrix = _reorder_by_cluster(association_matrix)
          else:
              pass  # Pearson Correlation does not need reordering
  
      return CorrelationWidget(
          association_matrix=association_matrix,
          cluster_matrix=cluster_matrix if cluster else None,
          viz_data=cluster_matrix if cluster else association_matrix,
      )
  
imports: import warnings
  import pandas
  import numpy
  from scipy.cluster import hierarchy
  from sklearn.metrics import matthews_corrcoef
  from scipy.stats import chi2_contingency
  import seaborn
  import matplotlib.pyplot
  import plotly.graph_objs
  import plotly.offline
  from data_describe.config._config import get_option
  from data_describe.misc.colors import get_p_RdBl_cmap, mpl_to_plotly_cmap
  from data_describe._widget import BaseWidget
  from data_describe.compat import _is_dataframe, _in_notebook, _requires
  from data_describe.backends import _get_viz_backend, _get_compute_backend
label_desc: Use image node_id 2 for calling a global function with example usage: _pandas_compute_correlation_matrix(data, cluster, categorical) and returns: CorrelationWidget