code: def _get_index_from_direction(direction):
      """Return numerical index from direction."""
      directions = ["x", "y", "z"]
      try:
          # l and r are subcases of x
          if direction in "lr":
              index = 0
          else:
              index = directions.index(direction)
      except ValueError:
          message = (
              f"{direction} is not a valid direction. "
              "Allowed values are 'l', 'r', 'x', 'y' and 'z'"
          )
          raise ValueError(message)
      return index
  
imports: import numbers
  import matplotlib.pyplot
  import numpy
  from matplotlib.colors import Normalize
  from matplotlib.font_manager import FontProperties
  from matplotlib.lines import Line2D
  from matplotlib.patches import FancyArrow
  from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
  from nilearn._utils.docs import fill_doc
  from nilearn.image import coord_transform
  from nilearn.plotting.glass_brain import plot_brain_schematics
label_desc: Use image node_id 1 for calling a global function with example usage: _get_index_from_direction(direction) and returns: index