code: def patch_use(enable_gui_function):
      
      matplotlib = sys.modules['matplotlib']
  
      def patched_use(*args, **kwargs):
          matplotlib.real_use(*args, **kwargs)
          gui, backend = find_gui_and_backend()
          enable_gui_function(gui)
  
      matplotlib.real_use = matplotlib.use
      matplotlib.use = patched_use
docs: Patch matplotlib function 'use'