code: def _replace_shard_suffix(filepath: str, replacement: str) -> str:
      """Replaces the shard suffix (must be at the end) with the given string."""
      (new_string, num_subs) = re.subn(
          pattern=r"^(.+?)-?\d{5,}(-of-\d{5,})?$",
          repl=rf"\g<1>{replacement}",
          string=filepath,
      )
      if num_subs != 1:
          raise RuntimeError(
              f"Should do 1 shard suffix substitution, but did {num_subs}! "
              f"Filepath was {filepath}"
          )
      return new_string
  
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 14 for calling a global function with example usage: _replace_shard_suffix(filepath, replacement) and returns: new_string