code: def _test_thread_impl():
      from concurrent.futures import ThreadPoolExecutor
  
      import matplotlib as mpl
      from matplotlib import pyplot as plt
  
      mpl.rcParams.update(
          {
              "webagg.open_in_browser": False,
              "webagg.port_retries": 1,
          }
      )
  
      # Test artist creation and drawing does not crash from thread
      # No other guarantees!
      fig, ax = plt.subplots()
      # plt.pause needed vs plt.show(block=False) at least on toolbar2-tkagg
      plt.pause(0.5)
  
      future = ThreadPoolExecutor().submit(ax.plot, [1, 3, 6])
      future.result()  # Joins the thread; rethrows any exception.
  
      fig.canvas.mpl_connect("close_event", print)
      future = ThreadPoolExecutor().submit(fig.canvas.draw)
      plt.pause(
          0.5
      )  # flush_events fails here on at least Tkagg (bpo-41176)
      future.result()  # Joins the thread; rethrows any exception.
      plt.close()  # backend is responsible for flushing any events here
      if plt.rcParams["backend"].startswith("WX"):
          # TODO: debug why WX needs this only on py >= 3.8
          fig.canvas.flush_events()
  
imports: import functools
  import importlib
  import importlib.util
  import inspect
  import json
  import os
  import platform
  import signal
  import subprocess
  import sys
  import tempfile
  import time
  import urllib.request
  from PIL import Image
  import pytest
  import matplotlib
  from matplotlib import _c_internal_utils
  from matplotlib.backend_tools import ToolToggleBase
  from matplotlib.testing import subprocess_run_helper
label_desc: Use image node_id 7 for calling a global function with example usage: _test_thread_impl() without return types