code: def compress_fixed_aspect(layoutgrids, fig):
      gs = None
      for ax in fig.axes:
          if ax.get_subplotspec() is None:
              continue
          ax.apply_aspect()
          sub = ax.get_subplotspec()
          _gs = sub.get_gridspec()
          if gs is None:
              gs = _gs
              extraw = np.zeros(gs.ncols)
              extrah = np.zeros(gs.nrows)
          elif _gs != gs:
              raise ValueError(
                  "Cannot do compressed layout if Axes are not"
                  "all from the same gridspec"
              )
          orig = ax.get_position(original=True)
          actual = ax.get_position(original=False)
          dw = orig.width - actual.width
          if dw > 0:
              extraw[sub.colspan] = np.maximum(extraw[sub.colspan], dw)
          dh = orig.height - actual.height
          if dh > 0:
              extrah[sub.rowspan] = np.maximum(extrah[sub.rowspan], dh)
  
      if gs is None:
          raise ValueError(
              "Cannot do compressed layout if no Axes "
              "are part of a gridspec."
          )
      w = np.sum(extraw) / 2
      layoutgrids[fig].edit_margin_min("left", w)
      layoutgrids[fig].edit_margin_min("right", w)
  
      h = np.sum(extrah) / 2
      layoutgrids[fig].edit_margin_min("top", h)
      layoutgrids[fig].edit_margin_min("bottom", h)
      return layoutgrids
  
file_path: matplotlib/lib/matplotlib/_constrained_layout.py
imports: import logging
  import numpy
  from matplotlib import _api, artist
  import matplotlib.transforms
  import matplotlib._layoutgrid
label_desc: Use image node_id 5 for calling a global function with example usage: compress_fixed_aspect(layoutgrids, fig) and returns: layoutgrids