code: def _cramers_v(x, y):
      """Calculates Cramer's V statistic for categorical-categorical association.
  
      Adapted from https://github.com/shakedzy/dython/blob/master/dython/nominal.py
  
      Args:
          x: A list, numpy array, or pandas series of categorical measurements
          y: A list, numpy array, or pandas series of categorical measurements
  
      Returns:
          Cramer's V value (float)
      """
      confusion_matrix = pd.crosstab(x, y)
      if (
          confusion_matrix.shape[0] == 2
          and confusion_matrix.shape[1] == 2
      ):
          # phi coefficient
          return matthews_corrcoef(x.astype(str), y.astype(str))
      else:
          # Cramer's V
          n = confusion_matrix.sum().sum()
          r, k = confusion_matrix.shape
          if n == k or n == r:
              return 1.0
          else:
              chi2 = chi2_contingency(confusion_matrix)[0]
              phi2 = chi2 / n
              phi2corr = max(0, phi2 - ((k - 1) * (r - 1)) / (n - 1))
              rcorr = r - ((r - 1) ** 2) / (n - 1)
              kcorr = k - ((k - 1) ** 2) / (n - 1)
              return np.sqrt(phi2corr / min((kcorr - 1), (rcorr - 1)))
  
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 4 for calling a global function with example usage: _cramers_v(x, y) and returns: matthews_corrcoef, int, np