docstr: Returns the SARIF Result representation of this diagnostic.
docstr_tok: ["Returns","the","SARIF","Result","representation","of","this","diagnostic","."]
code: def sarif(self) -> sarif.Result:
      """Returns the SARIF Result representation of this diagnostic."""
      message = self.message or self.rule.message_default_template
      if self.additional_messages:
          additional_message = "\n".join(self.additional_messages)
          message_markdown = f"{message}\n\n## Additional Message:\n\n{additional_message}"
      else:
          message_markdown = message
  
      kind: Literal["informational", "fail"] = (
          "informational" if self.level == infra.Level.NONE else "fail"
      )
  
      sarif_result = sarif.Result(
          message=sarif.Message(
              text=message, markdown=message_markdown
          ),
          level=self.level.name.lower(),  # type: ignore[arg-type]
          rule_id=self.rule.id,
          kind=kind,
      )
      sarif_result.locations = [
          location.sarif() for location in self.locations
      ]
      sarif_result.stacks = [stack.sarif() for stack in self.stacks]
      sarif_result.graphs = [graph.sarif() for graph in self.graphs]
      sarif_result.code_flows = [
          sarif.CodeFlow(
              thread_flows=[
                  sarif.ThreadFlow(
                      locations=[
                          loc.sarif()
                          for loc in self.thread_flow_locations
                      ]
                  )
              ]
          )
      ]
      sarif_result.properties = sarif.PropertyBag(
          tags=[tag.value for tag in self.tags]
      )
      return sarif_result
  
imports: from __future__ import annotations
  import contextlib
  import dataclasses
  import gzip
  import logging
  from typing import Callable, Generator, Generic, List, Literal, Mapping, Optional, Type, TypeVar
  from torch.onnx._internal.diagnostics import infra
  from torch.onnx._internal.diagnostics.infra import formatter, sarif, utils
  from torch.onnx._internal.diagnostics.infra.sarif import version
label_desc: Use image node_id 2 for calling the Diagnostic obj's underlying member method code with example usage: obj.sarif() and returns: sarif_result