code: def find_gui_and_backend(gui=None, gui_select=None):
      """Given a gui string return the gui and mpl backend.
  
      Parameters
      ----------
      gui : str
          Can be one of ('tk','gtk','wx','qt','qt4','inline','agg').
      gui_select : str
          Can be one of ('tk','gtk','wx','qt','qt4','inline').
          This is any gui already selected by the shell.
  
      Returns
      -------
      A tuple of (gui, backend) where backend is one of ('TkAgg','GTKAgg',
      'WXAgg','Qt4Agg','module://matplotlib_inline.backend_inline','agg').
      """
  
      import matplotlib
  
      has_unified_qt_backend = getattr(
          matplotlib, "__version_info__", (0, 0)
      ) >= (3, 5)
  
      backends_ = dict(backends)
      if not has_unified_qt_backend:
          backends_["qt"] = "qt5agg"
  
      if gui and gui != "auto":
          # select backend based on requested gui
          backend = backends_[gui]
          if gui == "agg":
              gui = None
      else:
          # We need to read the backend from the original data structure, *not*
          # from mpl.rcParams, since a prior invocation of %matplotlib may have
          # overwritten that.
          # WARNING: this assumes matplotlib 1.1 or newer!!
          backend = matplotlib.rcParamsOrig["backend"]
          # In this case, we need to find what the appropriate gui selection call
          # should be for IPython, so we can activate inputhook accordingly
          gui = backend2gui.get(backend, None)
  
          # If we have already had a gui active, we need it and inline are the
          # ones allowed.
          if gui_select and gui != gui_select:
              gui = gui_select
              backend = backends_[gui]
  
      return gui, backend
  
file_path: catboost/contrib/python/ipython/py3/IPython/core/pylabtools.py
imports: from io import BytesIO
  from binascii import b2a_base64
  from functools import partial
  import warnings
  from IPython.core.display import _pngxy
  from IPython.utils.decorators import flag_calls
label_desc: Use image node_id 8 for calling a global function with example usage: find_gui_and_backend(gui, gui_select) and returns: gui,  backend