code: def bokeh_palette(
      name, rawtext, text, lineno, inliner, options=None, content=None
  ):
      """Generate an inline visual representations of a single color palette.
  
      This function evaluates the expression ``f"palette = {text}"``, in the
      context of a ``globals`` namespace that has previously imported all of
      |bokeh.plotting|. The resulting value for ``palette`` is used to
      construct a sequence of HTML ``<span>`` elements for each color.
  
      If evaluating the palette expression fails or does not produce a list or
      tuple of all strings, then a SphinxError is raised to terminate the build.
  
      For details on the arguments to this function, consult the Docutils docs:
  
      http://docutils.sourceforge.net/docs/howto/rst-roles.html#define-the-role-function
  
      """
      try:
          exec(f"palette = {text}", _globals)
      except Exception as e:
          raise SphinxError(
              f"cannot evaluate palette expression {text!r}, reason: {e}"
          )
      p = _globals.get("palette", None)
      if not isinstance(p, (list, tuple)) or not all(
          isinstance(x, str) for x in p
      ):
          raise SphinxError(
              f"palette expression {text!r} generated invalid or no output: {p}"
          )
      w = (
          20
          if len(p) < 15
          else 10
          if len(p) < 32
          else 5
          if len(p) < 64
          else 2
          if len(p) < 128
          else 1
      )
      html = PALETTE_DETAIL.render(palette=p, width=w)
      node = nodes.raw("", html, format="html")
      return [node], []
  
file_path: bokeh/src/bokeh/sphinxext/bokeh_palette.py
imports: from __future__ import annotations
  import logging
  from docutils import nodes
  from sphinx.errors import SphinxError
  from .None import PARALLEL_SAFE
  from .templates import PALETTE_DETAIL
label_desc: Use image node_id 1 for calling a global function with example usage: bokeh_palette(name, rawtext, text, lineno, inliner, options, content) and returns: list,  list