docstr: Compute Chi-Squared test statistic and p-values per feature.
  
  Parameters
  ----------
  x_ref
      Reference instances to compare distribution with.
  x
      Batch of instances.
  
  Returns
  -------
  Feature level p-values and Chi-Squared statistics.
code: def feature_score(
      self, x_ref: np.ndarray, x: np.ndarray
  ) -> Tuple[np.ndarray, np.ndarray]:
      """
      Compute Chi-Squared test statistic and p-values per feature.
  
      Parameters
      ----------
      x_ref
          Reference instances to compare distribution with.
      x
          Batch of instances.
  
      Returns
      -------
      Feature level p-values and Chi-Squared statistics.
      """
      x_ref = x_ref.reshape(x_ref.shape[0], -1)
      x = x.reshape(x.shape[0], -1)
  
      # apply counts on union of categories per variable in both the reference and test data
      x_categories = {
          f: list(np.unique(x[:, f])) for f in range(self.n_features)
      }
      all_categories = {
          f: list(set().union(self.x_ref_categories[f], x_categories[f]))  # type: ignore
          for f in range(self.n_features)
      }
      x_ref_count = self._get_counts(x_ref, all_categories)
      x_count = self._get_counts(x, all_categories)
  
      p_val = np.zeros(self.n_features, dtype=np.float32)
      dist = np.zeros_like(p_val)
      for f in range(self.n_features):  # apply Chi-Squared test
          contingency_table = np.vstack((x_ref_count[f], x_count[f]))
          dist[f], p_val[f], _, _ = chi2_contingency(contingency_table)
      return p_val, dist
  
file_path: alibi-detect/alibi_detect/cd/chisquare.py
imports: import numpy
  from scipy.stats import chi2_contingency
  from typing import Callable, Dict, List, Optional, Tuple, Union
  from alibi_detect.cd.base import BaseUnivariateDrift
  from alibi_detect.utils.warnings import deprecated_alias
label_desc: Use image node_id 2 for calling the ChiSquareDrift obj's underlying member method code with example usage: obj.feature_score(x_ref, x) and returns: p_val,  dist