code: def _find_builder_dir(
      name: str, **builder_kwargs: Any
  ) -> Optional[str]:
      """Search whether the given dataset is present on disk and return its path.
  
      Note:
  
       * If the dataset is present, but is legacy (no feature config file), None
         is returned.
       * If the config isn't specified, the function tries to infer the default
         config name from the original `DatasetBuilder`.
       * The function searches in all `data_dir` registered with
         `tfds.core.add_data_dir`. If the dataset exists in multiple dirs, an error
         is raised.
  
      Args:
        name: Builder name (e.g. `my_ds`, `my_ds/config`, `my_ds:1.2.0`,...)
        **builder_kwargs: `tfds.core.DatasetBuilder` kwargs.
  
      Returns:
        path: The dataset path found, or None if the dataset isn't found.
      """
      # Normalize builder kwargs
      name, builder_kwargs = naming.parse_builder_name_kwargs(
          name, **builder_kwargs
      )
      version = builder_kwargs.pop("version", None)
      config = builder_kwargs.pop("config", None)
      data_dir = builder_kwargs.pop("data_dir", None)
  
      # Builder cannot be found if it uses:
      # * namespace
      # * version='experimental_latest'
      # * config objects (rather than `str`)
      # * custom DatasetBuilder.__init__ kwargs
      if (
          name.namespace
          or version == "experimental_latest"
          or isinstance(config, dataset_builder.BuilderConfig)
          or builder_kwargs
      ):
          error_msgs = [
              "Builder cannot be loaded from files if it uses:"
          ]
          if name.namespace:
              error_msgs.append(
                  f"* namespaces (here, {name.namespace} is used)"
              )
          if version == "experimental_latest":
              error_msgs.append(
                  "* `experimental_latest` as requested version."
              )
          if isinstance(config, dataset_builder.BuilderConfig):
              error_msgs.append("* config objects (rather than `str`).")
          if builder_kwargs:
              error_msgs.append(
                  "* custom DatasetBuilder.__init__ kwargs."
              )
          error_utils.add_context("\t".join(error_msgs))
          return None
  
      # Search the dataset across all registered data_dirs
      all_builder_dirs = []
      all_data_dirs = file_utils.list_data_dirs(given_data_dir=data_dir)
      for current_data_dir in all_data_dirs:
          builder_dir = _find_builder_dir_single_dir(
              name.name,
              data_dir=current_data_dir,
              version_str=str(version) if version else None,
              config_name=config,
          )
          if builder_dir:
              all_builder_dirs.append(builder_dir)
  
      if not all_builder_dirs:
          all_dirs_str = "\n\t- ".join(
              [""] + [str(dir) for dir in all_data_dirs]
          )
          error_msg = (
              f"No registered data_dirs were found in:{all_dirs_str}\n"
          )
          error_utils.add_context(error_msg)
          return None
  
      elif len(all_builder_dirs) != 1:
          # Rather than raising error every time, we could potentially be smarter
          # and load the most recent version across all files, but should be
          # careful when partial version is requested ('my_dataset:3.*.*').
          # Could add some `MultiDataDirManager` API:
          # ```
          # manager = MultiDataDirManager(given_data_dir=data_dir)
          # with manager.merge_data_dirs() as virtual_data_dir:
          #  virtual_builder_dir = _find_builder_dir(name, data_dir=virtual_data_dir)
          #  builder_dir = manager.resolve(virtual_builder_dir)
          # ```
          raise ValueError(
              f"Dataset {name} detected in multiple locations: {all_builder_dirs}. "
              "Please resolve the ambiguity by explicitly setting `data_dir=`."
          )
  
      return all_builder_dirs[0]
  
imports: import functools
  import os
  import typing
  from typing import Any, List, Optional, Tuple, Type
  from etils import epath
  from tensorflow_datasets.core import dataset_builder
  from tensorflow_datasets.core import dataset_info
  from tensorflow_datasets.core import logging
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import registered
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.features import feature
  from tensorflow_datasets.core.proto import dataset_info_pb2
  from tensorflow_datasets.core.utils import error_utils
  from tensorflow_datasets.core.utils import file_utils
  from tensorflow_datasets.core.utils import version
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 5 for calling a global function with example usage: _find_builder_dir(name) and returns: all_builder_dirs, None, None