code: def list_dataset_variants(
      dataset_dir: epath.PathLike,
      namespace: Optional[str] = None,
      include_versions: bool = True,
      include_old_tfds_version: bool = False,
  ) -> Iterator[naming.DatasetReference]:
      """Yields all variants (config + version) found in `dataset_dir`.
  
      Arguments:
        dataset_dir: the folder of the dataset.
        namespace: optional namespace to which this data dir belongs.
        include_versions: whether to list what versions are available.
        include_old_tfds_version: include datasets that have been generated with
          TFDS before 4.0.0.
  
      Yields:
        all variants of the given dataset.
      """
      dataset_dir = epath.Path(dataset_dir)
      references = {}
      for reference in _find_references_with_glob(
          folder=dataset_dir,
          is_data_dir=False,
          is_dataset_dir=True,
          namespace=namespace,
          include_old_tfds_version=include_old_tfds_version,
      ):
          if include_versions:
              key = f"{reference.dataset_name}/{reference.config}:{reference.version}"
          else:
              key = f"{reference.dataset_name}/{reference.config}"
              reference = reference.replace(version=None)
          references[key] = reference
  
      for reference in references.values():
          yield reference
  
imports: import collections
  import functools
  import os
  import re
  import time
  from typing import Iterator, List, Optional
  from absl import logging
  from etils import epath
  from tensorflow_datasets.core import constants
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core.utils import docs
  from tensorflow_datasets.core.utils import py_utils
  from tensorflow_datasets.core.utils import read_config
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils import version
label_desc: Use image node_id 9 for calling a global function with example usage: list_dataset_variants(dataset_dir, namespace, include_versions, include_old_tfds_version) without return types