code: def get_renderer(fig):
      if fig._cachedRenderer:
          renderer = fig._cachedRenderer
      else:
          canvas = fig.canvas
          if canvas and hasattr(canvas, "get_renderer"):
              renderer = canvas.get_renderer()
          else:
              # not sure if this can happen
              # seems to with PDF...
              _log.info(
                  "constrained_layout : falling back to Agg renderer"
              )
              from matplotlib.backends.backend_agg import (
                  FigureCanvasAgg,
              )
  
              canvas = FigureCanvasAgg(fig)
              renderer = canvas.get_renderer()
  
      return renderer
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import itertools
  import kiwisolver
  import logging
  import numpy
  import warnings
  import matplotlib
label_desc: Use image node_id 1 for calling a global function with example usage: get_renderer(fig) and returns: renderer