class_docstr: Test cases for diagnostics infra.
class_docstr_tok: ["Test","cases","for","diagnostics","infra","."]
code: def test_diagnostic_log_lazy_string_is_evaluated_once_when_level_not_less_than_diagnostic_options_verbosity_level(
      self,
  ):
      verbosity_level = logging.INFO
      self.context.options.verbosity_level = verbosity_level
      with self.context:
          diagnostic = infra.Diagnostic(
              self.rules.rule_without_message_args, infra.Level.NOTE
          )
  
          reference_val = 0
  
          def expensive_formatting_function() -> str:
              # Modify the reference_val to reflect this function is evaluated
              nonlocal reference_val
              reference_val += 1
              return f"expensive formatting {reference_val}"
  
          # `expensive_formatting_function` should NOT be evaluated.
          diagnostic.info(
              "%s", formatter.LazyString(expensive_formatting_function)
          )
          self.assertEqual(
              reference_val,
              1,
              "expensive_formatting_function should only be evaluated once after being wrapped under LazyString",
          )
  
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 7 for calling the TestDiagnosticsInfra obj's underlying member method code with example usage: obj.test_diagnostic_log_lazy_string_is_evaluated_once_when_level_not_less_than_diagnostic_options_verbosity_level() and returns: str, reference_val