[ONNX] Set 'Generic[Diagnostic]' as base class for 'DiagnosticContext' (#107165)
Allows overriding the `Diagnostic` type for DiagnosticContext and enable type checking.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/107165
Approved by: https://github.com/justinchuby, https://github.com/titaiwangms
ghstack dependencies: #106741, #107158