code: def _token_from_lexer_state(bold, fg_color, bg_color):
      """Construct a token given the current lexer state.
  
      We can only emit one token even though we have a multiple-tuple state.
      To do work around this, we construct tokens like "BoldRed".
      """
      token_name = ""
  
      if bold:
          token_name += "Bold"
  
      if fg_color:
          token_name += fg_color
  
      if bg_color:
          token_name += "BG" + bg_color
  
      if token_name == "":
          return pygments.token.Text
      else:
          return getattr(Color, token_name)
  
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 1 for calling a global function with example usage: _token_from_lexer_state(bold, fg_color, bg_color) and returns: pygments, getattr