class_docstr: Test cases for diagnostics emitted by the TorchScript ONNX export code.
class_docstr_tok: ["Test","cases","for","diagnostics","emitted","by","the","TorchScript","ONNX","export","code","."]
code: def test_diagnostics_records_cpp_call_stack(self):
      diagnostic = (
          self._trigger_node_missing_onnx_shape_inference_warning_diagnostic_from_cpp()
      )
      stack = diagnostic.cpp_call_stack
      assert stack is not None  # for mypy
      self.assertGreater(len(stack.frames), 0)
      frame_messages = [
          frame.location.message for frame in stack.frames
      ]
      # node missing onnx shape inference warning only comes from ToONNX (_jit_pass_onnx)
      # after node-level shape type inference and processed symbolic_fn output type
      self.assertTrue(
          any(
              isinstance(message, str)
              and "torch::jit::NodeToONNX" in message
              for message in frame_messages
          )
      )
  
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 8 for calling the TestTorchScriptOnnxDiagnostics obj's underlying member method code with example usage: obj.test_diagnostics_records_cpp_call_stack() without return types