code: def _assert_has_diagnostics(
      sarif_log_builder: _SarifLogBuilder,
      rule_level_pairs: AbstractSet[Tuple[infra.Rule, infra.Level]],
  ):
      sarif_log = sarif_log_builder.sarif_log()
      unseen_pairs = {
          (rule.id, level.name.lower())
          for rule, level in rule_level_pairs
      }
      actual_results = []
      for run in sarif_log.runs:
          if run.results is None:
              continue
          for result in run.results:
              id_level_pair = (result.rule_id, result.level)
              unseen_pairs.discard(id_level_pair)
              actual_results.append(id_level_pair)
  
      if unseen_pairs:
          raise AssertionError(
              f"Expected diagnostic results of rule id and level pair {unseen_pairs} not found. "
              f"Actual diagnostic results: {actual_results}"
          )
  
imports: from __future__ import annotations
  import contextlib
  import dataclasses
  import io
  import logging
  import typing
  import unittest
  from typing import AbstractSet, Protocol, Tuple
  import torch
  from torch.onnx import errors
  from torch.onnx._internal import diagnostics
  from torch.onnx._internal.diagnostics import infra
  from torch.onnx._internal.diagnostics.infra import formatter, sarif
  from torch.onnx._internal.fx import diagnostics
  from torch.testing._internal import common_utils, logging_utils
label_desc: Use image node_id 1 for calling a global function with example usage: _assert_has_diagnostics(sarif_log_builder, rule_level_pairs) without return types