code: def get_array_from_hist2D(hist: Hist, set_zero_to_NaN: bool = True, return_bin_edges: bool = False) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
      shape = (hist.GetYaxis().GetNbins(), hist.GetXaxis().GetNbins())
      hist_array = np.array([hist.GetBinContent(x) for x in range(1, hist.GetNcells()) if not hist.IsBinUnderflow(x) and not hist.IsBinOverflow(x)])
      hist_array = hist_array.reshape(shape)
      hist_array = hist_array.T
      if set_zero_to_NaN:
          hist_array[hist_array == 0] = np.nan
      if return_bin_edges:
          x_bin_edges = get_bin_edges_from_axis(hist.GetXaxis())
          y_bin_edges = get_bin_edges_from_axis(hist.GetYaxis())
          epsilon = 1e-9
          x_range = np.arange(
              np.amin(x_bin_edges),
              np.amax(x_bin_edges) + epsilon,
              hist.GetXaxis().GetBinWidth(1)
          )
          y_range = np.arange(
              np.amin(y_bin_edges),
              np.amax(y_bin_edges) + epsilon,
              hist.GetYaxis().GetBinWidth(1)
          )
      else:
          x_range = np.array([hist.GetXaxis().GetBinCenter(i) for i in range(1, hist.GetXaxis().GetNbins() + 1)])
          y_range = np.array([hist.GetYaxis().GetBinCenter(i) for i in range(1, hist.GetYaxis().GetNbins() + 1)])
      X, Y = np.meshgrid(x_range, y_range)
      return (X, Y, hist_array)