class_docstr: Template to produce filenames for sharded datasets.
  
  Attributes:
    data_dir: the directory that contains the files for the shards.
    template: template of the sharded files, e.g.
      '${SPLIT}/data.${FILEFORMAT}-${SHARD_INDEX}'.
    dataset_name: the name of the dataset.
    split: the split of the dataset.
    filetype_suffix: the filetype suffix to denote the type of file. For
      example, `tfrecord`.
docstr: Returns whether the given filename follows this template.
docstr_tok: ["Returns","whether","the","given","filename","follows","this","template","."]
code: def is_valid(self, filename: str) -> bool:
      """Returns whether the given filename follows this template."""
      filename_info = self.parse_filename_info(filename)
      if filename_info is None:
          return False
  
      # Even when `dataset_name` is set, it may not be in the template,
      # so also test that `filename_info.dataset_name` is not None`.`
      if (
          self.dataset_name is not None
          and filename_info.dataset_name is not None
          and filename_info.dataset_name != self.dataset_name
      ):
          return False
      if (
          self.split is not None
          and filename_info.split is not None
          and filename_info.split != self.split
      ):
          return False
      if (
          self.filetype_suffix is not None
          and filename_info.filetype_suffix is not None
          and filename_info.filetype_suffix != self.filetype_suffix
      ):
          return False
      return True
  
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 4 for calling the ShardedFileTemplate obj's underlying member method code with example usage: obj.is_valid(filename) and returns: True, False, False, False, False