code: def chi_square(
      values: Optional[np.ndarray] = None,
      histogram: Optional[np.ndarray] = None,
  ) -> dict:
      if histogram is None:
          bins = np.histogram_bin_edges(values, bins="auto")
          histogram, _ = np.histogram(values, bins=bins)
      return dict(chisquare(histogram)._asdict())
  
imports: import functools
  from typing import Any, Callable, Optional, Tuple, TypeVar
  import numpy
  import pandas
  from multimethod import multimethod
  from scipy.stats import chisquare
  from ydata_profiling.config import Settings
label_desc: Use image node_id 3 for calling a global function with example usage: chi_square(values, histogram) and returns: dict