code: def make_axes_gridspec(parent, **kw):
      """
      Resize and reposition a parent axes, and return a child axes
      suitable for a colorbar. This function is similar to
      make_axes. Prmary differences are
  
       * *make_axes_gridspec* only handles the *orientation* keyword
         and cannot handle the "location" keyword.
  
       * *make_axes_gridspec* should only be used with a subplot parent.
  
       * *make_axes* creates an instance of Axes. *make_axes_gridspec*
          creates an instance of Subplot.
  
       * *make_axes* updates the position of the
          parent. *make_axes_gridspec* replaces the grid_spec attribute
          of the parent with a new one.
  
      While this function is meant to be compatible with *make_axes*,
      there could be some minor differences.
  
      Keyword arguments may include the following (with defaults):
  
          *orientation*
              'vertical' or 'horizontal'
  
      %s
  
      All but the first of these are stripped from the input kw set.
  
      Returns (cax, kw), the child axes and the reduced kw dictionary to be
      passed when creating the colorbar instance.
      """
  
      orientation = kw.setdefault("orientation", "vertical")
      kw["ticklocation"] = "auto"
  
      fraction = kw.pop("fraction", 0.15)
      shrink = kw.pop("shrink", 1.0)
      aspect = kw.pop("aspect", 20)
  
      x1 = 1 - fraction
  
      # for shrinking
      pad_s = (1 - shrink) * 0.5
      wh_ratios = [pad_s, shrink, pad_s]
  
      # we need to none the tree of layoutboxes because
      # constrained_layout can't remove and replace the tree
      # hierarchy w/o a seg fault.
      gs = parent.get_subplotspec().get_gridspec()
      layoutbox.nonetree(gs._layoutbox)
      gs_from_subplotspec = gridspec.GridSpecFromSubplotSpec
      if orientation == "vertical":
          pad = kw.pop("pad", 0.05)
          wh_space = 2 * pad / (1 - pad)
          gs = gs_from_subplotspec(
              1,
              2,
              subplot_spec=parent.get_subplotspec(),
              wspace=wh_space,
              width_ratios=[x1 - pad, fraction],
          )
          gs2 = gs_from_subplotspec(
              3,
              1,
              subplot_spec=gs[1],
              hspace=0.0,
              height_ratios=wh_ratios,
          )
          anchor = (0.0, 0.5)
          panchor = (1.0, 0.5)
      else:
          pad = kw.pop("pad", 0.15)
          wh_space = 2 * pad / (1 - pad)
          gs = gs_from_subplotspec(
              2,
              1,
              subplot_spec=parent.get_subplotspec(),
              hspace=wh_space,
              height_ratios=[x1 - pad, fraction],
          )
          gs2 = gs_from_subplotspec(
              1,
              3,
              subplot_spec=gs[1],
              wspace=0.0,
              width_ratios=wh_ratios,
          )
          aspect = 1 / aspect
          anchor = (0.5, 1.0)
          panchor = (0.5, 0.0)
  
      parent.set_subplotspec(gs[0])
      parent.update_params()
      parent._set_position(parent.figbox)
      parent.set_anchor(panchor)
  
      fig = parent.get_figure()
      cax = fig.add_subplot(gs2[1])
      cax.set_aspect(aspect, anchor=anchor, adjustable="box")
      return cax, kw
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  from six.moves import xrange, zip
  import warnings
  import numpy
  import matplotlib
  import matplotlib.artist
  import matplotlib.cbook
  import matplotlib.collections
  import matplotlib.colors
  import matplotlib.contour
  import matplotlib.cm
  import matplotlib.gridspec
  import matplotlib.patches
  import matplotlib.path
  import matplotlib.ticker
  import matplotlib.transforms
  import matplotlib._layoutbox
  import matplotlib._constrained_layout
  from matplotlib import docstring
label_desc: Use image node_id 3 for calling a global function with example usage: make_axes_gridspec(parent) and returns: cax,  kw