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_python_call_stack(self):
      diagnostic = diagnostics.TorchScriptOnnxExportDiagnostic(self._sample_rule, diagnostics.levels.NOTE)  # fmt: skip
      # Do not break the above line, otherwise it will not work with Python-3.8+
      stack = diagnostic.python_call_stack
      assert stack is not None  # for mypy
      self.assertGreater(len(stack.frames), 0)
      frame = stack.frames[0]
      assert frame.location.snippet is not None  # for mypy
      self.assertIn("self._sample_rule", frame.location.snippet)
      assert frame.location.uri is not None  # for mypy
      self.assertIn("test_diagnostics.py", frame.location.uri)
  
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 TestTorchScriptOnnxDiagnostics obj's underlying member method code with example usage: obj.test_diagnostics_records_python_call_stack() without return types