code: def create_labels(da, labels, locations, direction):
      """
      Return an OffsetBox with label texts
      """
      # The box dimensions are determined by the size of
      # the text objects. We put two dummy children at
      # either end to gaurantee that when center packed
      # the labels in the labels_box matchup with the ticks.
      from matplotlib.text import Text
  
      from .._mpl.offsetbox import MyAuxTransformBox
  
      fontsize = 9
      labels_box = MyAuxTransformBox()
      xs, ys = [0] * len(labels), locations
      ha, va = "left", "center"
  
      x1, y1 = 0, 0
      x2, y2 = 0, da.height
      if direction == "horizontal":
          xs, ys = ys, xs
          ha, va = "center", "top"
          x2, y2 = da.width, 0
      txt1 = Text(
          x1, y1, "", horizontalalignment=ha, verticalalignment=va
      )
      txt2 = Text(
          x2, y2, "", horizontalalignment=ha, verticalalignment=va
      )
      labels_box.add_artist(txt1)
      labels_box.add_artist(txt2)
  
      legend_text = []
      for i, (x, y, text) in enumerate(zip(xs, ys, labels)):
          txt = Text(
              x,
              y,
              text,
              size=fontsize,
              horizontalalignment=ha,
              verticalalignment=va,
          )
          labels_box.add_artist(txt)
          legend_text.append(txt)
      return labels_box, legend_text
  
imports: from __future__ import annotations
  import hashlib
  import typing
  from warnings import warn
  import numpy
  import pandas
  from mizani.bounds import rescale
  from ..exceptions import PlotnineWarning
  from ..mapping.aes import rename_aesthetics
  from ..scales.scale_continuous import scale_continuous
  from .guide import guide
label_desc: Use image node_id 4 for calling a global function with example usage: create_labels(da, labels, locations, direction) and returns: labels_box,  legend_text