code: def color_tokens(fg_colors, bg_colors):
      """Return color tokens for a given set of colors.
  
      Pygments doesn't have a generic "color" token; instead everything is
      contextual (e.g. "comment" or "variable"). That doesn't make sense for us,
      where the colors actually *are* what we care about.
  
      This function will register combinations of tokens (things like "Red" or
      "BoldRedBGGreen") based on the colors passed in.
  
      You can also define the tokens yourself, but note that the token names are
      *not* currently guaranteed to be stable between releases as I'm not really
      happy with this approach.
  
      Usage:
  
          fg_colors = bg_colors = {
              'Black': '#000000',
              'Red': '#EF2929',
              'Green': '#8AE234',
              'Yellow': '#FCE94F',
              'Blue': '#3465A4',
              'Magenta': '#c509c5',
              'Cyan': '#34E2E2',
              'White': '#ffffff',
          }
          class MyStyle(pygments.styles.SomeStyle):
              styles = dict(pygments.styles.SomeStyle.styles)
              styles.update(color_tokens(fg_colors, bg_colors))
      """
      styles = {}
  
      for bold, fg_color, bg_color in itertools.product(
          (False, True),
          {None} | set(fg_colors),
          {None} | set(bg_colors),
      ):
          token = _token_from_lexer_state(bold, fg_color, bg_color)
          if token is not pygments.token.Text:
              value = []
              if bold:
                  value.append("bold")
              if fg_color:
                  value.append(fg_colors[fg_color])
              if bg_color:
                  value.append("bg:" + bg_colors[bg_color])
              styles[token] = " ".join(value)
  
      return styles
  
file_path: datalad/docs/utils/pygments_ansi_color.py
imports: from __future__ import absolute_import
  from __future__ import unicode_literals
  import itertools
  import re
  import pygments.lexer
  import pygments.token
label_desc: Use image node_id 2 for calling a global function with example usage: color_tokens(fg_colors, bg_colors) and returns: styles