code: def hist_compare(row, hist_name1: str = "", hist_name2: str = ""):
      """Function to compare two histograms
  
      Apply statistical tests to compare two input histograms, such as:
      Chi2, KS, Pearson, max probability difference.
      For categorical histograms, also check for unknown labels.
  
      :param pd.Series row: row to apply compare function to
      :param str hist_name1: name of histogram one to compare
      :param str hist_name2: name of histogram two to compare
      :return: pandas Series with popular comparison metrics.
      """
      from popmon.analysis.comparison import Comparisons
  
      x = {key: np.nan for key in Comparisons.get_keys()}
  
      # basic name checks
      cols = row.index.to_list()
      if (
          len(hist_name1) == 0
          or len(hist_name2) == 0
          and len(cols) == 2
      ):
          hist_name1 = cols[0]
          hist_name2 = cols[1]
      if not all(name in cols for name in [hist_name1, hist_name2]):
          raise ValueError(
              "Need to provide two histogram column names."
          )
  
      # basic histogram checks
      hist1 = row[hist_name1]
      hist2 = row[hist_name2]
      if not all(
          isinstance(hist, COMMON_HIST_TYPES) for hist in [hist1, hist2]
      ) or not check_similar_hists([hist1, hist2]):
          return pd.Series(x)
  
      # compare
      if hist1.n_dim == 1:
          entries_list = get_consistent_numpy_entries([hist1, hist2])
          if is_numeric(hist1):
              htype = "num"
              args = entries_list
          else:
              htype = "cat"
              args = [hist1, hist2]
  
          x.update(Comparisons.run(args, dim=1, htype=htype))
          x.update(Comparisons.run(entries_list, dim=1, htype="all"))
      else:
          numpy_ndgrids = get_consistent_numpy_ndgrids(
              [hist1, hist2], dim=hist1.n_dim
          )
          entries_list = [entry.flatten() for entry in numpy_ndgrids]
  
          x.update(Comparisons.run(entries_list, dim=(2,), htype="all"))
  
      x.update(Comparisons.run(entries_list, dim=-1, htype="all"))
  
      if len(set(x.keys()) - set(Comparisons.get_keys())) > 0:
          raise ValueError("Could not compute full comparison")
  
      return pd.Series(x)
  
imports: import numpy
  import pandas
  from popmon.analysis.apply_func import ApplyFunc
  from popmon.analysis.functions import expand_norm_hist_mean_cov, expanding_hist, hist_sum, normalized_hist_mean_cov, relative_chi_squared, roll_norm_hist_mean_cov, rolling_hist
  from popmon.analysis.hist_numpy import check_similar_hists, get_consistent_numpy_entries, get_consistent_numpy_ndgrids
  from popmon.base import Pipeline
  from popmon.hist.hist_utils import COMMON_HIST_TYPES, is_numeric
label_desc: Use image node_id 1 for calling a global function with example usage: hist_compare(row, hist_name1, hist_name2) and returns: pd, pd