code: def calculate_cat_assoc_matrix(data, categorical_variables, n):
      from scipy.stats import chi2_contingency
  
      cat_assoc_matrix = pd.DataFrame(
          index=categorical_variables,
          columns=categorical_variables,
          dtype=float,
      )
      for i, variable_name_a in enumerate(categorical_variables):
          for j, variable_name_b in enumerate(categorical_variables):
              if i > j:
                  continue  # matrix is symmetric
              elif i == j:
                  cramers_V = 1
              else:
                  # calculate Cramér’s V with bias correction
                  cont_tab = pd.crosstab(
                      data[variable_name_a], data[variable_name_b]
                  )
                  r = cont_tab.shape[0]
                  c = cont_tab.shape[1]
                  chi2_test = chi2_contingency(cont_tab)
                  phi = max(
                      0,
                      (chi2_test[0] / n)
                      - (((r - 1) * (c - 1)) / (n - 1)),
                  )
                  r = r - ((r - 1) ** 2 / (n - 1))
                  c = c - ((c - 1) ** 2 / (n - 1))
                  cramers_V = np.sqrt(phi / (min(c, r) - 1))
                  cramers_V = checks.check_assoc_value(cramers_V)
              cat_assoc_matrix.loc[
                  variable_name_a, variable_name_b
              ] = cramers_V
              cat_assoc_matrix.loc[
                  variable_name_b, variable_name_a
              ] = cramers_V
      return cat_assoc_matrix
  
file_path: DALEX/python/dalex/dalex/aspect/utils.py
imports: import numpy
  import pandas
  import warnings
  from .None import checks
  from ..None import _global_checks
label_desc: Use image node_id 1 for calling a global function with example usage: calculate_cat_assoc_matrix(data, categorical_variables, n) and returns: cat_assoc_matrix