code: def get_consistent_numpy_ndgrids(
      hist_list=None, get_bin_labels: bool = False, dim: int = 3
  ):
      """Get list of consistent x,y grids of first n dimensions of (sparse) input histograms
  
      :param list hist_list: list of input histogrammar histograms
      :param bool get_bin_labels: if true, return x-keys and y-keys describing binnings of 2d-grid.
      :param int dim: number of dimension (>= 3)
      :return: list of consistent x,y grids of first two dimensions of each input histogram in list
      """
      # --- basic checks
      if hist_list is None or len(hist_list) == 0:
          raise ValueError("Input histogram list has zero length.")
      if hist_list[0].n_dim < dim:
          raise ValueError(
              f"Input histogram only has {hist_list[0].n_dim} dimensions (<{dim}). Cannot compute {dim}d-grid."
          )
      assert_similar_hists(hist_list)
  
      keys: list[set] = [set() for _ in range(dim)]
      for hist in hist_list:
          hist_keys = prepare_ndgrid(hist, n_dim=dim)
          for i, h_keys in enumerate(hist_keys):
              keys[i] |= set(h_keys)
      sorted_keys = [sorted(k) for k in keys]
  
      gridnd_list = [
          set_ndgrid(hist, sorted_keys, n_dim=dim) for hist in hist_list
      ]
  
      if get_bin_labels:
          return gridnd_list, sorted_keys
  
      return gridnd_list
  
imports: from __future__ import annotations
  import warnings
  import histogrammar
  import numpy
  from histogrammar.util import get_hist_props
  from popmon.hist.hist_utils import get_bin_centers, is_numeric
  from popmon.stats.numpy import quantile
label_desc: Use image node_id 7 for calling a global function with example usage: get_consistent_numpy_ndgrids(hist_list, get_bin_labels, dim) and returns: gridnd_list, gridnd_list,  sorted_keys