code: def _get_builder_cls(
      ds_to_build: str,
      *,
      has_imports: bool,
  ) -> Tuple[Type[tfds.core.DatasetBuilder], Dict[str, str]]:
      """Infer the builder class to build.
  
      Args:
        ds_to_build: Dataset argument.
        has_imports: Whether `--imports` was passed
  
      Returns:
        builder_cls: The dataset class to download and prepare
        kwargs:
      """
      # 1st case: Requested dataset is a path to `.py` script
      # When `--imports=` is set, it means the user expects the dataset to be
      # registered through the `imports` and not locally.
      if not has_imports:
          path = _search_script_path(ds_to_build)
          if path is not None:
              logging.info(
                  f"Loading dataset {ds_to_build} from path: {path}"
              )
              # Dynamically load user dataset script
              # When possible, load from the parent's parent, so module is named
              # "foo.foo_dataset_builder".
              try:
                  with tfds.core.utils.add_sys_path(path.parent.parent):
                      builder_cls = (
                          tfds.core.community.builder_cls_from_module(
                              f"{path.parent.stem}.{path.stem}"
                          )
                      )
                  return builder_cls, {}
              except ImportError:
                  pass
              # There might be cases where user imports from a legacy builder module,
              # in which case the above wouldn't necessarily work, so we fall back to
              # importing the module directly.
              with tfds.core.utils.add_sys_path(path.parent):
                  builder_cls = (
                      tfds.core.community.builder_cls_from_module(
                          path.stem
                      )
                  )
              return builder_cls, {}
  
      # 2nd case: Dataset is registered through imports.
  
      # Extract `name/config:version`
      name, builder_kwargs = tfds.core.naming.parse_builder_name_kwargs(
          ds_to_build
      )
      builder_cls = tfds.builder_cls(str(name))
      logging.info(
          f"Loading dataset {ds_to_build} from imports: {builder_cls.__module__}"
      )
      builder_kwargs = typing.cast(Dict[str, str], builder_kwargs)
      return builder_cls, builder_kwargs
  
imports: import argparse
  import functools
  import importlib
  import itertools
  import json
  import multiprocessing
  import os
  import typing
  from typing import Dict, Iterator, Optional, Tuple, Type, Union
  from absl import logging
  from etils import epath
  import tensorflow_datasets
label_desc: Use image node_id 4 for calling a global function with example usage: _get_builder_cls(ds_to_build) and returns: builder_cls,  builder_kwargs, builder_cls,  dict, builder_cls,  dict