code: def add_offsetboxes(ax, size=10, margin=0.1, color="black"):
      """
      Surround ax with OffsetBoxes
      """
      m, mp = margin, 1 + margin
      anchor_points = [
          (-m, -m),
          (-m, 0.5),
          (-m, mp),
          (mp, 0.5),
          (0.5, mp),
          (mp, mp),
          (0.5, -m),
          (mp, -m),
          (0.5, -m),
      ]
      for point in anchor_points:
          da = DrawingArea(size, size)
          background = Rectangle(
              (0, 0),
              width=size,
              height=size,
              facecolor=color,
              edgecolor="None",
              linewidth=0,
              antialiased=False,
          )
          da.add_artist(background)
  
          anchored_box = AnchoredOffsetbox(
              loc="center",
              child=da,
              pad=0.0,
              frameon=False,
              bbox_to_anchor=point,
              bbox_transform=ax.transAxes,
              borderpad=0.0,
          )
          ax.add_artist(anchored_box)
      return anchored_box
  
imports: import warnings
  import numpy
  from numpy.testing import assert_array_equal
  import pytest
  import matplotlib
  from matplotlib.testing.decorators import image_comparison
  import matplotlib.pyplot
  from matplotlib.offsetbox import AnchoredOffsetbox, DrawingArea
  from matplotlib.patches import Rectangle
label_desc: Use image node_id 12 for calling a global function with example usage: add_offsetboxes(ax, size, margin, color) and returns: anchored_box