code: def charFormat(color, style="", background=None):
      """
      Return a QTextCharFormat with the given attributes.
      """
      _color = QColor()
      if type(color) is not str:
          _color.setRgb(color[0], color[1], color[2])
      else:
          _color.setNamedColor(color)
  
      _format = QTextCharFormat()
      _format.setForeground(_color)
      if "bold" in style:
          _format.setFontWeight(QFont.Weight.Bold)
      if "italic" in style:
          _format.setFontItalic(True)
      if background is not None:
          _format.setBackground(pg.mkColor(background))
  
      return _format
  
imports: import keyword
  import os
  import pkgutil
  import re
  import subprocess
  import sys
  from argparse import Namespace
  from collections import OrderedDict
  from functools import lru_cache
  import pyqtgraph
  from pyqtgraph.Qt import QT_LIB, QtCore, QtGui, QtWidgets
  import exampleLoaderTemplate_generic
  import utils
label_desc: Use image node_id 1 for calling a global function with example usage: charFormat(color, style, background) and returns: _format