class_docstr: A base class of GridSpec that specifies the geometry of the grid
  that a subplot will be placed.
class_docstr_tok: ["A","base","class","of","GridSpec","that","specifies","the","geometry","of","the","grid","that","a","subplot","will","be","placed","."]
docstr: Create and return a `.SubplotSpec` instance.
code: def __getitem__(self, key):
      """Create and return a `.SubplotSpec` instance."""
      nrows, ncols = self.get_geometry()
  
      def _normalize(key, size, axis):  # Includes last index.
          orig_key = key
          if isinstance(key, slice):
              start, stop, _ = key.indices(size)
              if stop > start:
                  return start, stop - 1
              raise IndexError(
                  "GridSpec slice would result in no space "
                  "allocated for subplot"
              )
          else:
              if key < 0:
                  key = key + size
              if 0 <= key < size:
                  return key, key
              elif axis is not None:
                  raise IndexError(
                      f"index {orig_key} is out of bounds for "
                      f"axis {axis} with size {size}"
                  )
              else:  # flat index
                  raise IndexError(
                      f"index {orig_key} is out of bounds for "
                      f"GridSpec with size {size}"
                  )
  
      if isinstance(key, tuple):
          try:
              k1, k2 = key
          except ValueError as err:
              raise ValueError("Unrecognized subplot spec") from err
          num1, num2 = np.ravel_multi_index(
              [_normalize(k1, nrows, 0), _normalize(k2, ncols, 1)],
              (nrows, ncols),
          )
      else:  # Single key
          num1, num2 = _normalize(key, nrows * ncols, None)
  
      return SubplotSpec(self, num1, num2)
  
imports: import copy
  import logging
  from numbers import Integral
  import numpy
  import matplotlib
  from matplotlib import _api, _pylab_helpers, _tight_layout
  from matplotlib.transforms import Bbox
label_desc: Use image node_id 12 for calling the GridSpecBase obj's underlying member method code with example usage: obj.__getitem__(key) and returns: SubplotSpec, start,  unknown, key,  key