code: def layoutcolorbarsingle(ax, cax, shrink, aspect, location, pad=0.05):
      """
      Do the layout for a colorbar, to not oeverly pollute colorbar.py
  
      `pad` is in fraction of the original axis size.
      """
      axlb = ax._layoutbox
      axpos = ax._poslayoutbox
      axsslb = ax.get_subplotspec()._layoutbox
      lb = layoutbox.LayoutBox(
          parent=axsslb, name=axsslb.name + ".cbar", artist=cax
      )
  
      if location in ("left", "right"):
          lbpos = layoutbox.LayoutBox(
              parent=lb,
              name=lb.name + ".pos",
              tightwidth=False,
              pos=True,
              subplot=False,
              artist=cax,
          )
  
          if location == "right":
              # arrange to right of parent axis
              layoutbox.hstack(
                  [axlb, lb],
                  padding=pad * axlb.width,
                  strength="strong",
              )
          else:
              layoutbox.hstack([lb, axlb], padding=pad * axlb.width)
          # constrain the height and center...
          layoutbox.match_heights([axpos, lbpos], [1, shrink])
          layoutbox.align([axpos, lbpos], "v_center")
          # set the width of the pos box
          lbpos.constrain_width(
              shrink * axpos.height * (1 / aspect), strength="strong"
          )
      elif location in ("bottom", "top"):
          lbpos = layoutbox.LayoutBox(
              parent=lb,
              name=lb.name + ".pos",
              tightheight=True,
              pos=True,
              subplot=False,
              artist=cax,
          )
  
          if location == "bottom":
              layoutbox.vstack([axlb, lb], padding=pad * axlb.height)
          else:
              layoutbox.vstack([lb, axlb], padding=pad * axlb.height)
          # constrain the height and center...
          layoutbox.match_widths(
              [axpos, lbpos], [1, shrink], strength="strong"
          )
          layoutbox.align([axpos, lbpos], "h_center")
          # set the height of the pos box
          lbpos.constrain_height(
              axpos.width * aspect * shrink, strength="medium"
          )
  
      return lb, lbpos
  
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 6 for calling a global function with example usage: layoutcolorbarsingle(ax, cax, shrink, aspect, location, pad) and returns: lb,  lbpos