code: def _pygmented_with_ranges(formatter, code, ranges):
      import pygments
      from pygments.lexers import get_lexer_by_name
  
      class MyLexer(type(get_lexer_by_name("python3"))):
          def get_tokens(self, text):
              length = 0
              for ttype, value in super().get_tokens(text):
                  if any(
                      start <= length < end for start, end in ranges
                  ):
                      ttype = ttype.ExecutingNode
                  length += len(value)
                  yield ttype, value
  
      lexer = MyLexer(stripnl=False)
      try:
          highlighted = pygments.highlight(code, lexer, formatter)
      except Exception:
          # When pygments fails, prefer code without highlighting over crashing
          highlighted = code
      return highlighted.splitlines()
  
imports: import ast
  import itertools
  import types
  from collections import OrderedDict, Counter, defaultdict
  from types import FrameType, TracebackType
  from typing import Iterator, List, Tuple, Iterable, Callable, Union, TypeVar, Mapping
  from asttokens import ASTText
label_desc: Use image node_id 11 for calling a global function with example usage: _pygmented_with_ranges(formatter, code, ranges) and returns: highlighted