code: def chi2_kernel(X, Y=None, gamma=1.0):
      """Compute the exponential chi-squared kernel between X and Y.
  
      The chi-squared kernel is computed between each pair of rows in X and Y.  X
      and Y have to be non-negative. This kernel is most commonly applied to
      histograms.
  
      The chi-squared kernel is given by::
  
          k(x, y) = exp(-gamma Sum [(x - y)^2 / (x + y)])
  
      It can be interpreted as a weighted difference per entry.
  
      Read more in the :ref:`User Guide <chi2_kernel>`.
  
      Parameters
      ----------
      X : array-like of shape (n_samples_X, n_features)
          A feature array.
  
      Y : ndarray of shape (n_samples_Y, n_features), default=None
          An optional second feature array. If `None`, uses `Y=X`.
  
      gamma : float, default=1
          Scaling parameter of the chi2 kernel.
  
      Returns
      -------
      kernel_matrix : ndarray of shape (n_samples_X, n_samples_Y)
          The kernel matrix.
  
      See Also
      --------
      additive_chi2_kernel : The additive version of this kernel.
      sklearn.kernel_approximation.AdditiveChi2Sampler : A Fourier approximation
          to the additive version of this kernel.
  
      References
      ----------
      * Zhang, J. and Marszalek, M. and Lazebnik, S. and Schmid, C.
        Local features and kernels for classification of texture and object
        categories: A comprehensive study
        International Journal of Computer Vision 2007
        https://hal.archives-ouvertes.fr/hal-00171412/document
      """
      K = additive_chi2_kernel(X, Y)
      K *= gamma
      return np.exp(K, K)
  
imports: import itertools
  import warnings
  from functools import partial
  import numpy
  from joblib import effective_n_jobs
  from scipy.sparse import csr_matrix, issparse
  from scipy.spatial import distance
  from ..None import config_context
  from ..exceptions import DataConversionWarning
  from ..preprocessing import normalize
  from ..utils import check_array, gen_batches, gen_even_slices, get_chunk_n_rows, is_scalar_nan
  from ..utils._mask import _get_mask
  from ..utils._param_validation import Hidden, Integral, Interval, MissingValues, Options, Real, StrOptions, validate_params
  from ..utils.extmath import row_norms, safe_sparse_dot
  from ..utils.fixes import parse_version, sp_base_version
  from ..utils.parallel import Parallel, delayed
  from ..utils.validation import _num_samples, check_non_negative
  from ._pairwise_distances_reduction import ArgKmin
  from ._pairwise_fast import _chi2_kernel_fast, _sparse_manhattan
label_desc: Use image node_id 26 for calling a global function with example usage: chi2_kernel(X, Y, gamma) and returns: np