code: def _filename_template_to_regex(filename_template: str) -> str:
      """Returns the regular expression for the given template.
  
      Arguments:
        filename_template: the filename template to create a regex for.
  
      Returns:
        the regular expression for the filename template.
  
      Raises:
        ValueError: when not all variables in the template were substituted.
      """
      result = filename_template.replace(".", r"\.")
      for var, regex in _VAR_REGEX_MAPPING.items():
          result = result.replace(f"{{{var}}}", regex)
      if re.match(re.compile(r"\{\w+\}"), result):
          raise ValueError(
              "Regex still contains variables "
              f"that have not been substituted: {result}"
          )
      return result
  
imports: from __future__ import annotations
  import dataclasses
  import functools
  import os
  import re
  import textwrap
  from typing import Any, Dict, List, Mapping, MutableMapping, Optional, Tuple, Union
  from absl import logging
  from etils import epath
  from tensorflow_datasets.core.utils import py_utils
  from tensorflow_datasets.core.utils import version
label_desc: Use image node_id 15 for calling a global function with example usage: _filename_template_to_regex(filename_template) and returns: result