code: def _construct_filename_template(
      data_dir: epath.PathLike,
      filename_template: Union[
          None, str, naming.ShardedFileTemplate
      ] = None,
  ) -> naming.ShardedFileTemplate:
      """Returns a basic filename template based on the given data dir and template."""
      data_dir = epath.Path(data_dir)
      if filename_template is None:
          filename_template = naming.ShardedFileTemplate(
              data_dir=data_dir,
              template=naming.DEFAULT_FILENAME_TEMPLATE,
          )
      elif isinstance(filename_template, str):
          filename_template = naming.ShardedFileTemplate(
              data_dir=data_dir, template=filename_template
          )
      return filename_template.replace(data_dir=data_dir)
  
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 2 for calling a global function with example usage: _construct_filename_template(data_dir, filename_template) and returns: filename_template