code: def _arange_subplotspecs(gs, hspace=0, wspace=0):
      """
      arange the subplotspec children of this gridspec, and then recursively
      do the same of any gridspec children of those gridspecs...
      """
      sschildren = []
      for child in gs.children:
          if child._is_subplotspec_layoutbox():
              for child2 in child.children:
                  # check for gridspec children...
                  if child2._is_gridspec_layoutbox():
                      _arange_subplotspecs(
                          child2, hspace=hspace, wspace=wspace
                      )
              sschildren += [child]
      # now arrange the subplots...
      for child0 in sschildren:
          ss0 = child0.artist
          nrows, ncols = ss0.get_gridspec().get_geometry()
          if ss0.num2 is None:
              ss0.num2 = ss0.num1
          rowNum0min, colNum0min = divmod(ss0.num1, ncols)
          rowNum0max, colNum0max = divmod(ss0.num2, ncols)
          sschildren = sschildren[1:]
          for childc in sschildren:
              ssc = childc.artist
              rowNumCmin, colNumCmin = divmod(ssc.num1, ncols)
              if ssc.num2 is None:
                  ssc.num2 = ssc.num1
              rowNumCmax, colNumCmax = divmod(ssc.num2, ncols)
              # OK, this tells us the relative layout of ax
              # with axc
              thepad = wspace / ncols
              if colNum0max < colNumCmin:
                  layoutbox.hstack(
                      [ss0._layoutbox, ssc._layoutbox], padding=thepad
                  )
              if colNumCmax < colNum0min:
                  layoutbox.hstack(
                      [ssc._layoutbox, ss0._layoutbox], padding=thepad
                  )
  
              ####
              # vertical alignment
              thepad = hspace / nrows
              if rowNum0max < rowNumCmin:
                  layoutbox.vstack(
                      [ss0._layoutbox, ssc._layoutbox], padding=thepad
                  )
              if rowNumCmax < rowNum0min:
                  layoutbox.vstack(
                      [ssc._layoutbox, ss0._layoutbox], padding=thepad
                  )
  
file_path: catboost/contrib/python/matplotlib/py2/matplotlib/_constrained_layout.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy
  import logging
  import warnings
  from matplotlib.legend import Legend
  import matplotlib.transforms
  import matplotlib._layoutbox
label_desc: Use image node_id 5 for calling a global function with example usage: _arange_subplotspecs(gs, hspace, wspace) without return types