code: def build_catalog(
      datasets: Optional[List[str]] = None,
      ds_collections: Optional[List[str]] = None,
      *,
      catalog_dir: Optional[epath.PathLike] = None,
      doc_util_paths: Optional[doc_utils.DocUtilPaths] = None,
      toc_relative_path: str = "/datasets/catalog/",
      index_template: Optional[epath.PathLike] = None,
      index_filename: str = "overview.md",
      dataset_types: Optional[
          List[tfds.core.visibility.DatasetType]
      ] = None,
      include_collections: bool = True,
  ) -> None:
      """Document all datasets, including the table of content.
  
      Args:
        datasets: Lists of dataset to document (all if not set)
        ds_collections: Lists of all dataset collections to document (all if not
          set)
        catalog_dir: Destination path for the catalog
        doc_util_paths: Additional path for visualization, nightly info,...
        toc_relative_path: Relative path of the catalog directory, used to generate
          the table of content relative links.
        index_template: Default template for the index page.
        index_filename: Name of the catalog index file.
        dataset_types: Restrict the generation to the given dataset types. Default
          to all open source non-community datasets
        include_collections: Whether to include dataset collections to the catalog.
          Default to True.
      """
      dataset_types = dataset_types or [
          tfds.core.visibility.DatasetType.TFDS_PUBLIC,
      ]
      tfds.core.visibility.set_availables(dataset_types)
  
      catalog_dir = tfds.core.Path(catalog_dir)
      index_template = index_template or tfds.core.tfds_path(
          "scripts/documentation/templates/catalog_overview.md"
      )
      index_template = tfds.core.Path(index_template)
  
      # Iterate over the builder documentations
      section_to_builder_docs = collections.defaultdict(list)
      for builder_doc in document_datasets.iter_documentation_builders(
          datasets,
          doc_util_paths=doc_util_paths or doc_utils.DocUtilPaths(),
      ):
          # Write the builder documentation
          dataset_file = catalog_dir / f"{builder_doc.filestem}.md"
          dataset_file.write_text(builder_doc.content)
          # Save the category
          for section in builder_doc.sections:
              section_to_builder_docs[section].append(builder_doc)
  
      section_to_collection_docs = collections.defaultdict(list)
      if include_collections:
          # Iterate over the dataset collection documentations
          for (
              collection_doc
          ) in document_datasets.iter_collections_documentation(
              ds_collections
          ):
              # Write the dataset collection documentation
              collection_file = (
                  catalog_dir / f"{collection_doc.name}.md"
              )
              collection_file.write_text(collection_doc.content)
              # Save the "dataset collection" docs
              section_to_collection_docs["collections"].append(
                  collection_doc
              )
  
      _save_table_of_content(
          catalog_dir=catalog_dir,
          section_to_builder_docs=section_to_builder_docs,
          section_to_collection_docs=section_to_collection_docs,
          toc_relative_path=toc_relative_path,
          index_template=index_template,
          index_filename=index_filename,
          include_collections=include_collections,
      )
  
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 5 for calling a global function with example usage: build_catalog(datasets, ds_collections) without return types