code: def gen_diagnostics_cpp(
      rules: Sequence[_RuleType], out_cpp_dir: str, template_dir: str
  ) -> None:
      rule_lines = [_format_rule_for_cpp(rule) for rule in rules]
      rule_names = [
          f'"{_kebab_case_to_snake_case(rule["name"])}",'
          for rule in rules
      ]
  
      fm = torchgen_utils.FileManager(
          install_dir=out_cpp_dir,
          template_dir=template_dir,
          dry_run=False,
      )
      fm.write_with_template(
          "rules.h",
          "rules.h.in",
          lambda: {
              "generated_comment": textwrap.indent(
                  _RULES_GENERATED_COMMENT,
                  " * ",
                  predicate=lambda x: True,  # Don't ignore empty line
              ),
              "rules": textwrap.indent("\n".join(rule_lines), " " * 2),
              "py_rule_names": textwrap.indent(
                  "\n".join(rule_names), " " * 4
              ),
          },
      )
      _lint_file(os.path.join(out_cpp_dir, "rules.h"))
  
file_path: pytorch/tools/onnx/gen_diagnostics.py
imports: import argparse
  import os
  import string
  import subprocess
  import textwrap
  from typing import Any, Mapping, Sequence
  import yaml
  from torchgen import utils
  from torchgen.yaml_utils import YamlLoader
label_desc: Use image node_id 7 for calling a global function with example usage: gen_diagnostics_cpp(rules, out_cpp_dir, template_dir) without return types