code: def pytest_runtest_protocol(
      item: Item,
  ) -> Generator[None, None, None]:
      """Setup the pytest_assertrepr_compare and pytest_assertion_pass hooks.
  
      The rewrite module will use util._reprcompare if it exists to use custom
      reporting via the pytest_assertrepr_compare hook.  This sets up this custom
      comparison for the test.
      """
  
      ihook = item.ihook
  
      def callbinrepr(op, left: object, right: object) -> Optional[str]:
          """Call the pytest_assertrepr_compare hook and prepare the result.
  
          This uses the first result from the hook and then ensures the
          following:
          * Overly verbose explanations are truncated unless configured otherwise
            (eg. if running in verbose mode).
          * Embedded newlines are escaped to help util.format_explanation()
            later.
          * If the rewrite mode is used embedded %-characters are replaced
            to protect later % formatting.
  
          The result can be formatted by util.format_explanation() for
          pretty printing.
          """
          hook_result = ihook.pytest_assertrepr_compare(
              config=item.config, op=op, left=left, right=right
          )
          for new_expl in hook_result:
              if new_expl:
                  new_expl = truncate.truncate_if_required(
                      new_expl, item
                  )
                  new_expl = [
                      line.replace("\n", "\\n") for line in new_expl
                  ]
                  res = "\n~".join(new_expl)
                  if item.config.getvalue("assertmode") == "rewrite":
                      res = res.replace("%", "%%")
                  return res
          return None
  
      saved_assert_hooks = util._reprcompare, util._assertion_pass
      util._reprcompare = callbinrepr
      util._config = item.config
  
      if ihook.pytest_assertion_pass.get_hookimpls():
  
          def call_assertion_pass_hook(
              lineno: int, orig: str, expl: str
          ) -> None:
              ihook.pytest_assertion_pass(
                  item=item, lineno=lineno, orig=orig, expl=expl
              )
  
          util._assertion_pass = call_assertion_pass_hook
  
      yield
  
      util._reprcompare, util._assertion_pass = saved_assert_hooks
      util._config = None
  
imports: import sys
  from typing import Any
  from typing import Generator
  from typing import List
  from typing import Optional
  from typing import TYPE_CHECKING
  from _pytest.assertion import rewrite
  from _pytest.assertion import truncate
  from _pytest.assertion import util
  from _pytest.assertion.rewrite import assertstate_key
  from _pytest.config import Config
  from _pytest.config import hookimpl
  from _pytest.config.argparsing import Parser
  from _pytest.nodes import Item
label_desc: Use image node_id 5 for calling a global function with example usage: pytest_runtest_protocol(item) and returns: None, res