code: def _check(name, input, idDict, output, key, asTextOutput):
      if key is None:
          key = name
      key += " "
      if name in ("function", "member"):
          inputActual = input
          outputAst = output
          outputAsText = output
      else:
          inputActual = input.format(key="")
          outputAst = output.format(key="")
          outputAsText = output.format(key=key)
      if asTextOutput is not None:
          outputAsText = asTextOutput
  
      # first a simple check of the AST
      ast = parse(name, inputActual)
      res = str(ast)
      if res != outputAst:
          print("")
          print("Input:    ", input)
          print("Result:   ", res)
          print("Expected: ", outputAst)
          raise DefinitionError
      rootSymbol = Symbol(None, None, None, None, None, None, None)
      symbol = rootSymbol.add_declaration(
          ast, docname="TestDoc", line=42
      )
      parentNode = addnodes.desc()
      signode = addnodes.desc_signature(input, "")
      parentNode += signode
      ast.describe_signature(signode, "lastIsName", symbol, options={})
      resAsText = parentNode.astext()
      if resAsText != outputAsText:
          print("")
          print("Input:    ", input)
          print("astext(): ", resAsText)
          print("Expected: ", outputAsText)
          print("Node:", parentNode)
          raise DefinitionError
  
      idExpected = [None]
      for i in range(1, _max_id + 1):
          if i in idDict:
              idExpected.append(idDict[i])
          else:
              idExpected.append(idExpected[i - 1])
      idActual = [None]
      for i in range(1, _max_id + 1):
          try:
              id = ast.get_id(version=i)
              assert id is not None
              idActual.append(id[len(_id_prefix[i]) :])
          except NoOldIdError:
              idActual.append(None)
  
      res = [True]
      for i in range(1, _max_id + 1):
          res.append(idExpected[i] == idActual[i])
  
      if not all(res):
          print("input:    %s" % input.rjust(20))
          for i in range(1, _max_id + 1):
              if res[i]:
                  continue
              print("Error in id version %d." % i)
              print("result:   %s" % idActual[i])
              print("expected: %s" % idExpected[i])
          print(rootSymbol.dump(0))
          raise DefinitionError
  
imports: import itertools
  import re
  import zlib
  import pytest
  import sphinx.domains.cpp
  from sphinx import addnodes
  from sphinx.addnodes import desc, desc_content, desc_name, desc_parameter, desc_parameterlist, desc_sig_name, desc_sig_space, desc_signature, desc_signature_line, pending_xref
  from sphinx.domains.cpp import DefinitionError, DefinitionParser, NoOldIdError, Symbol, _id_prefix, _max_id
  from sphinx.ext.intersphinx import load_mappings, normalize_intersphinx_mapping
  from sphinx.testing import restructuredtext
  from sphinx.testing.util import assert_node
  from sphinx.writers.text import STDINDENT
label_desc: Use image node_id 2 for calling a global function with example usage: _check(name, input, idDict, output, key, asTextOutput) without return types