code: def create_export_diagnostic_context() -> (
      Generator[infra.DiagnosticContext, None, None]
  ):
      """Create a diagnostic context for export.
  
      This is a workaround for code robustness since diagnostic context is accessed by
      export internals via global variable. See `ExportDiagnosticEngine` for more details.
      """
      global _context
      assert (
          _context == engine.background_context
      ), "Export context is already set. Nested export is not supported."
      _context = engine.create_diagnostic_context(
          "torch.onnx.export",
          torch.__version__,
      )
      try:
          yield _context
      finally:
          _context = engine.background_context
  
imports: from __future__ import annotations
  import contextlib
  import gzip
  from collections.abc import Generator
  from typing import List, Optional
  import torch
  from torch.onnx._internal.diagnostics import infra
  from torch.onnx._internal.diagnostics.infra import formatter, sarif
  from torch.onnx._internal.diagnostics.infra.sarif import version
  from torch.utils import cpp_backtrace
label_desc: Use image node_id 2 for calling a global function with example usage: create_export_diagnostic_context() without return types