code: def _save_table_of_content(
      catalog_dir: tfds.core.Path,
      section_to_builder_docs: Dict[
          str, List[document_datasets.BuilderDocumentation]
      ],
      section_to_collection_docs: Dict[
          str, List[document_datasets.CollectionDocumentation]
      ],
      toc_relative_path: str,
      index_template: tfds.core.Path,
      index_filename: str,
      include_collections: bool,
  ) -> None:
      """Builds and saves the table of contents (`_toc.yaml` and `overview.md`)."""
      # For _toc.yaml
      toc_yaml = {
          "toc": [
              {
                  "title": "Overview",
                  "path": os.path.join(toc_relative_path, "overview"),
              }
          ]
      }
      # For overview.md
      toc_overview = []
  
      # All collections documented, save the table of content
      if include_collections:
          for section, collection_docs in sorted(
              section_to_collection_docs.items()
          ):
              collection_docs = sorted(
                  collection_docs, key=lambda doc: doc.name
              )
  
              # Add `_toc.yaml` section
              sec_dict = {"title": "Dataset Collections", "section": []}
              for doc in collection_docs:
                  sidebar_item = {
                      "path": os.path.join(toc_relative_path, doc.name),
                      "title": doc.name,
                  }
                  sec_dict["section"].append(sidebar_item)
              toc_yaml["toc"].append(sec_dict)
  
              # Add `overview.md` section
              toc_overview.append(
                  _create_collections_section_toc(collection_docs)
              )
  
      # All builder documented, save the table of content
      for section, builder_docs in sorted(
          section_to_builder_docs.items()
      ):
          builder_docs = sorted(builder_docs, key=lambda doc: doc.name)
  
          # Add `_toc.yaml` section
          sec_dict = {"title": section, "section": []}
          for doc in builder_docs:
              sidebar_item = {
                  "path": os.path.join(toc_relative_path, doc.filestem),
                  "title": doc.name
                  + (" (manual)" if doc.is_manual else ""),
              }
              if doc.is_nightly:
                  sidebar_item["status"] = "nightly"
              sec_dict["section"].append(sidebar_item)
          toc_yaml["toc"].append(sec_dict)
  
          # Add `overview.md` section
          toc_overview.append(
              _create_datasets_section_toc(section, builder_docs)
          )
  
      # Write the `overview.md` page
      index_str = index_template.read_text().format(
          toc="\n".join(toc_overview)
      )
      catalog_dir.joinpath(index_filename).write_text(index_str)
  
      # Write the `_toc.yaml` TF documentation navigation bar
      with catalog_dir.joinpath("_toc.yaml").open("w") as f:
          yaml.dump(toc_yaml, f, default_flow_style=False)
  
file_path: datasets/tensorflow_datasets/scripts/documentation/build_catalog.py
imports: import argparse
  import collections
  import os
  from typing import Dict, List, Optional
  from absl import app
  from absl.flags import argparse_flags
  from etils import epath
  import tensorflow_datasets
  from tensorflow_datasets.scripts.documentation import doc_utils
  from tensorflow_datasets.scripts.documentation import document_datasets
  import yaml
label_desc: Use image node_id 6 for calling a global function with example usage: _save_table_of_content(catalog_dir, section_to_builder_docs, section_to_collection_docs, toc_relative_path, index_template, index_filename, include_collections) without return types