code: def _enrich_filename_template(
      filename_template: naming.ShardedFileTemplate,
      file_infos: Sequence[naming.FilenameInfo],
  ) -> naming.ShardedFileTemplate:
      """Enriches the given template with data from the given file infos."""
      # Use set with tuple expansion syntax to ensure all names are consistent.
      (dataset_name,) = {f.dataset_name for f in file_infos}
      if (
          filename_template.dataset_name
          and dataset_name
          and filename_template.dataset_name != dataset_name
      ):
          raise ValueError(
              f"Detected dataset name {dataset_name}, but "
              f"{filename_template.dataset_name} was specified "
              "in the filename template!"
          )
      elif dataset_name:
          # dataset_name can be None if the files don't specify the name
          filename_template = filename_template.replace(
              dataset_name=dataset_name
          )
  
      (filetype_suffix,) = {f.filetype_suffix for f in file_infos}
      if (
          filename_template.filetype_suffix
          and filename_template.filetype_suffix != filetype_suffix
      ):
          raise ValueError(
              f"Detected filetype suffix {filetype_suffix}, but "
              f"{filename_template.filetype_suffix} was specified "
              "in the filename template!"
          )
      elif filetype_suffix:
          # filetype_suffix can be None if the files don't specify the name
          filename_template = filename_template.replace(
              filetype_suffix=filetype_suffix
          )
  
      return filename_template
  
file_path: datasets/tensorflow_datasets/core/folder_dataset/write_metadata_utils.py
imports: from collections.abc import Sequence
  import os
  from typing import Union
  from etils import epath
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import read_only_builder
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.folder_dataset import compute_split_utils
label_desc: Use image node_id 3 for calling a global function with example usage: _enrich_filename_template(filename_template, file_infos) and returns: filename_template