code: def create_renderer(glyphclass, plot, **kwargs):
      # convert data source, if necessary
      is_user_source = _convert_data_source(kwargs)
  
      # save off legend kwargs before we get going
      legend_kwarg = pop_legend_kwarg(kwargs)
  
      # need to check if user source is present before pop_renderer_args
      renderer_kws = _pop_renderer_args(kwargs)
      source = renderer_kws["data_source"]
  
      # handle the main glyph, need to process literals
      glyph_visuals = pop_visuals(glyphclass, kwargs)
      incompatible_literal_spec_values = []
      incompatible_literal_spec_values += _process_sequence_literals(
          glyphclass, kwargs, source, is_user_source
      )
      incompatible_literal_spec_values += _process_sequence_literals(
          glyphclass, glyph_visuals, source, is_user_source
      )
      if incompatible_literal_spec_values:
          raise RuntimeError(
              _GLYPH_SOURCE_MSG
              % nice_join(
                  incompatible_literal_spec_values, conjunction="and"
              )
          )
  
      # handle the nonselection glyph, we always set one
      nonselection_visuals = pop_visuals(
          glyphclass,
          kwargs,
          prefix="nonselection_",
          defaults=glyph_visuals,
          override_defaults={"alpha": 0.1},
      )
  
      # handle the selection glyph, if any properties were given
      if any(x.startswith("selection_") for x in kwargs):
          selection_visuals = pop_visuals(
              glyphclass,
              kwargs,
              prefix="selection_",
              defaults=glyph_visuals,
          )
      else:
          selection_visuals = None
  
      # handle the hover glyph, if any properties were given
      if any(x.startswith("hover_") for x in kwargs):
          hover_visuals = pop_visuals(
              glyphclass,
              kwargs,
              prefix="hover_",
              defaults=glyph_visuals,
          )
      else:
          hover_visuals = None
  
      # handle the mute glyph, we always set one
      muted_visuals = pop_visuals(
          glyphclass,
          kwargs,
          prefix="muted_",
          defaults=glyph_visuals,
          override_defaults={"alpha": 0.2},
      )
  
      glyph = make_glyph(glyphclass, kwargs, glyph_visuals)
      nonselection_glyph = make_glyph(
          glyphclass, kwargs, nonselection_visuals
      )
      selection_glyph = make_glyph(
          glyphclass, kwargs, selection_visuals
      )
      hover_glyph = make_glyph(glyphclass, kwargs, hover_visuals)
      muted_glyph = make_glyph(glyphclass, kwargs, muted_visuals)
  
      glyph_renderer = GlyphRenderer(
          glyph=glyph,
          nonselection_glyph=nonselection_glyph or "auto",
          selection_glyph=selection_glyph or "auto",
          hover_glyph=hover_glyph,
          muted_glyph=muted_glyph or "auto",
          **renderer_kws,
      )
  
      plot.renderers.append(glyph_renderer)
  
      if legend_kwarg:
          # It must be after the renderer is added because
          # if it creates a new `LegendItem`, the referenced
          # renderer must already be present.
          update_legend(plot, legend_kwarg, glyph_renderer)
  
      return glyph_renderer
  
file_path: bokeh/src/bokeh/plotting/_renderer.py
imports: from __future__ import annotations
  import logging
  import sys
  from collections.abc import Iterable
  import numpy
  from ..core.properties import ColorSpec
  from ..models import ColumnarDataSource, ColumnDataSource, GlyphRenderer
  from ..util.strings import nice_join
  from ._legends import pop_legend_kwarg, update_legend
label_desc: Use image node_id 2 for calling a global function with example usage: create_renderer(glyphclass, plot) and returns: glyph_renderer