code: def test_picking(child_type, boxcoords):
      # These all take up approximately the same area.
      if child_type == "draw":
          picking_child = DrawingArea(5, 5)
          picking_child.add_artist(
              mpatches.Rectangle((0, 0), 5, 5, linewidth=0)
          )
      elif child_type == "image":
          im = np.ones((5, 5))
          im[2, 2] = 0
          picking_child = OffsetImage(im)
      elif child_type == "text":
          picking_child = TextArea(
              "\N{Black Square}", textprops={"fontsize": 5}
          )
      else:
          assert False, f"Unknown picking child type {child_type}"
  
      fig, ax = plt.subplots()
      ab = AnnotationBbox(
          picking_child, (0.5, 0.5), boxcoords=boxcoords
      )
      ab.set_picker(True)
      ax.add_artist(ab)
  
      calls = []
      fig.canvas.mpl_connect(
          "pick_event", lambda event: calls.append(event)
      )
  
      # Annotation should be picked by an event occurring at its center.
      if boxcoords == "axes points":
          x, y = ax.transAxes.transform_point((0, 0))
          x += 0.5 * fig.dpi / 72
          y += 0.5 * fig.dpi / 72
      elif boxcoords == "axes pixels":
          x, y = ax.transAxes.transform_point((0, 0))
          x += 0.5
          y += 0.5
      else:
          x, y = ax.transAxes.transform_point((0.5, 0.5))
      fig.canvas.draw()
      calls.clear()
      MouseEvent(
          "button_press_event", fig.canvas, x, y, MouseButton.LEFT
      )._process()
      assert len(calls) == 1 and calls[0].artist == ab
  
      # Annotation should *not* be picked by an event at its original center
      # point when the limits have changed enough to hide the *xy* point.
      ax.set_xlim(-1, 0)
      ax.set_ylim(-1, 0)
      fig.canvas.draw()
      calls.clear()
      MouseEvent(
          "button_press_event", fig.canvas, x, y, MouseButton.LEFT
      )._process()
      assert len(calls) == 0
  
imports: from collections import namedtuple
  import io
  import numpy
  from numpy.testing import assert_allclose
  import pytest
  from matplotlib.testing.decorators import check_figures_equal, image_comparison
  import matplotlib.pyplot
  import matplotlib.patches
  import matplotlib.lines
  from matplotlib.backend_bases import MouseButton, MouseEvent
  from matplotlib.offsetbox import AnchoredOffsetbox, AnnotationBbox, AnchoredText, DrawingArea, HPacker, OffsetBox, OffsetImage, PaddedBox, TextArea, VPacker, _get_packed_offsets
label_desc: Use image node_id 10 for calling a global function with example usage: test_picking(child_type, boxcoords) without return types