code: def lex(code, lexer):
      """
      Lex ``code`` with ``lexer`` and return an iterable of tokens.
      """
      try:
          return lexer.get_tokens(code)
      except TypeError as err:
          if isinstance(err.args[0], str) and (
              "unbound method get_tokens" in err.args[0]
              or "missing 1 required positional argument" in err.args[0]
          ):
              raise TypeError(
                  "lex() argument must be a lexer instance, "
                  "not a class"
              )
          raise
  
imports: import sys
  from pygments.util import StringIO, BytesIO
label_desc: Use image node_id 1 for calling a global function with example usage: lex(code, lexer) and returns: lexer