[torch/csrc/onnx] Use nested namespaces (3/N) (#113993)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/113993
Approved by: https://github.com/ZainRizvi
ghstack dependencies: #113991, #113992
diff --git a/tools/onnx/templates/rules.h.in b/tools/onnx/templates/rules.h.in
index 4c81806..c4ec775 100644
--- a/tools/onnx/templates/rules.h.in
+++ b/tools/onnx/templates/rules.h.in
@@ -4,9 +4,7 @@
 ${generated_comment}
  */
 
-namespace torch {
-namespace onnx {
-namespace diagnostics {
+namespace torch::onnx::diagnostics {
 
 enum class Rule : uint32_t {
 ${rules}
@@ -16,6 +14,4 @@
 ${py_rule_names}
 };
 
-} // namespace diagnostics
-} // namespace onnx
-} // namespace torch
+} // namespace torch::onnx::diagnostics
diff --git a/torch/csrc/onnx/diagnostics/diagnostics.h b/torch/csrc/onnx/diagnostics/diagnostics.h
index 7c78e30..1255d91 100644
--- a/torch/csrc/onnx/diagnostics/diagnostics.h
+++ b/torch/csrc/onnx/diagnostics/diagnostics.h
@@ -3,9 +3,7 @@
 #include <torch/csrc/utils/pybind.h>
 #include <string>
 
-namespace torch {
-namespace onnx {
-namespace diagnostics {
+namespace torch::onnx::diagnostics {
 
 /**
  * @brief Level of a diagnostic.
@@ -61,6 +59,4 @@
       py_rule, py_level, py_message, "cpp_stack"_a = true);
 }
 
-} // namespace diagnostics
-} // namespace onnx
-} // namespace torch
+} // namespace torch::onnx::diagnostics