code: def list_datasets_in_data_dir(
      data_dir: epath.PathLike,
      namespace: Optional[str] = None,
      include_configs: bool = True,
      include_versions: bool = True,
      include_old_tfds_version: bool = False,
  ) -> Iterator[naming.DatasetReference]:
      """Yields references to the datasets found in `data_dir`.
  
      Only finds datasets that were written to `data_dir`. This means that if
      `data_dir` contains a sub-folder with datasets in them, that these will not be
      found.
  
      Arguments:
        data_dir: the folder where to look for datasets.
        namespace: optional namespace to which this data dir belongs.
        include_configs: whether to list what configs are available.
        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:
        references to the datasets found in `data_dir`. The references include the
        data dir.
      """
      for dataset_dir in epath.Path(data_dir).iterdir():
          if not dataset_dir.is_dir():
              continue
          if not naming.is_valid_dataset_name(dataset_dir.name):
              continue
          if include_configs:
              yield from list_dataset_variants(
                  dataset_dir=dataset_dir,
                  namespace=namespace,
                  include_versions=include_versions,
                  include_old_tfds_version=include_old_tfds_version,
              )
          else:
              yield naming.DatasetReference(
                  dataset_name=dataset_dir.name,
                  namespace=namespace,
                  data_dir=data_dir,
              )
  
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 10 for calling a global function with example usage: list_datasets_in_data_dir(data_dir, namespace, include_configs, include_versions, include_old_tfds_version) without return types