code: def histogram_compute(
      config: Settings,
      finite_values: np.ndarray,
      n_unique: int,
      name: str = "histogram",
      weights: Optional[np.ndarray] = None,
  ) -> dict:
      stats = {}
      hist_config = config.plot.histogram
      bins_arg = (
          "auto"
          if hist_config.bins == 0
          else min(hist_config.bins, n_unique)
      )
      bins = np.histogram_bin_edges(finite_values, bins=bins_arg)
      if len(bins) > hist_config.max_bins:
          bins = np.histogram_bin_edges(
              finite_values, bins=hist_config.max_bins
          )
          weights = (
              weights
              if weights and len(weights) == hist_config.max_bins
              else None
          )
  
      stats[name] = np.histogram(
          finite_values,
          bins=bins,
          weights=weights,
          density=config.plot.histogram.density,
      )
  
      return stats
  
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 2 for calling a global function with example usage: histogram_compute(config, finite_values, n_unique, name, weights) and returns: stats