code: def test_contourf_legend_elements():
      x, y = np.mgrid[1:10, 1:10]
      h = x * y
  
      fig, ax = plt.subplots(subplot_kw=dict(projection="3d"))
      cs = ax.contourf(
          x,
          y,
          h,
          levels=[10, 30, 50],
          colors=["#FFFF00", "#FF00FF", "#00FFFF"],
          extend="both",
      )
      cs.cmap.set_over("red")
      cs.cmap.set_under("blue")
      cs.changed()
      artists, labels = cs.legend_elements()
      assert labels == [
          "$x \\leq -1e+250s$",
          "$10.0 < x \\leq 30.0$",
          "$30.0 < x \\leq 50.0$",
          "$x > 1e+250s$",
      ]
      expected_colors = ("blue", "#FFFF00", "#FF00FF", "red")
      assert all(isinstance(a, mpl.patches.Rectangle) for a in artists)
      assert all(
          same_color(a.get_facecolor(), c)
          for a, c in zip(artists, expected_colors)
      )
  
file_path: matplotlib/lib/mpl_toolkits/mplot3d/tests/test_legend3d.py
imports: import numpy
  import matplotlib
  from matplotlib.colors import same_color
  from matplotlib.testing.decorators import image_comparison
  import matplotlib.pyplot
  from mpl_toolkits.mplot3d import art3d
label_desc: Use image node_id 7 for calling a global function with example usage: test_contourf_legend_elements() without return types