code: def new_figure_manager_given_figure(num, figure):
      """
      Return a new figure manager for a given figure instance.
  
      This function is part of the API expected by Matplotlib backends.
      """
      manager = backend_agg.new_figure_manager_given_figure(num, figure)
  
      # Hack: matplotlib FigureManager objects in interacive backends (at least
      # in some of them) monkeypatch the figure object and add a .show() method
      # to it.  This applies the same monkeypatch in order to support user code
      # that might expect `.show()` to be part of the official API of figure
      # objects.  For further reference:
      # https://github.com/ipython/ipython/issues/1612
      # https://github.com/matplotlib/matplotlib/issues/835
  
      if not hasattr(figure, "show"):
          # Queue up `figure` for display
          figure.show = lambda *a: display(
              figure, metadata=_fetch_figure_metadata(figure)
          )
  
      # If matplotlib was manually set to non-interactive mode, this function
      # should be a no-op (otherwise we'll generate duplicate plots, since a user
      # who set ioff() manually expects to make separate draw/show calls).
      if not matplotlib.is_interactive():
          return manager
  
      # ensure current figure will be drawn, and each subsequent call
      # of draw_if_interactive() moves the active figure to ensure it is
      # drawn last
      try:
          show._to_draw.remove(figure)
      except ValueError:
          # ensure it only appears in the draw list once
          pass
      # Queue up the figure for drawing in next show() call
      show._to_draw.append(figure)
      show._draw_called = True
  
      return manager
  
imports: import matplotlib
  from matplotlib import colors
  from matplotlib.backends import backend_agg
  from matplotlib.backends.backend_agg import FigureCanvasAgg
  from matplotlib._pylab_helpers import Gcf
  from matplotlib.figure import Figure
  from IPython.core.interactiveshell import InteractiveShell
  from IPython.core.getipython import get_ipython
  from IPython.core.pylabtools import select_figure_formats
  from IPython.display import display
  from .config import InlineBackend
label_desc: Use image node_id 2 for calling a global function with example usage: new_figure_manager_given_figure(num, figure) and returns: manager, manager