# Path: core/Util.py
# def import_submodules(package_name):
#   package = sys.modules[package_name]
#   for importer, name, is_package in pkgutil.walk_packages(package.__path__):
#     # not sure why this check is necessary...
#     if not importer.path.startswith(package.__path__[0]):
#       continue
#     name_with_package = package_name + "." + name
#     importlib.import_module(name_with_package)
#     if is_package:
#       import_submodules(name_with_package)


from core.Util import import_submodules

_registered_datasets = {}


def register_dataset(name, **args):
  name = name.lower()

  def _register(dataset):
    _registered_datasets[name] = (dataset, args)
    return dataset
  return _register


def load_dataset(config, subset, session, name):
  if not hasattr(load_dataset, "_imported"):
    load_dataset._imported = True

# Path: core/Util.py
# def import_submodules(package_name):
#   package = sys.modules[package_name]
#   for importer, name, is_package in pkgutil.walk_packages(package.__path__):
#     # not sure why this check is necessary...
#     if not importer.path.startswith(package.__path__[0]):
#       continue
#     name_with_package = package_name + "." + name
#     importlib.import_module(name_with_package)
#     if is_package:
#       import_submodules(name_with_package)


# Path: datasets/Loader.py
from core.Util import import_submodules


_registered_datasets = {}


def register_dataset(name, **args):
  name = name.lower()

  def _register(dataset):
    _registered_datasets[name] = (dataset, args)
    return dataset
  return _register


def load_dataset(config, subset, session, name):
  if not hasattr(load_dataset, "_imported"):
    load_dataset._imported = True

    import_submodules("datasets")