code: def _download_and_cache(package: DatasetPackage) -> _InstalledPackage:
      """Downloads and installs locally the dataset source.
  
      This function install the dataset package in:
      `<module_path>/<namespace>/<ds_name>/<hash>/...`.
  
      Args:
        package: Package to install.
  
      Returns:
        installed_dataset: The installed dataset package.
      """
      tmp_dir = epath.Path(tempfile.mkdtemp())
      try:
          # Download the package in a tmp directory
          dataset_sources_lib.download_from_source(
              package.source,
              tmp_dir,
          )
  
          # Compute the package hash (to install the dataset in a unique dir)
          package_hash = _compute_dir_hash(tmp_dir)
  
          # Add package metadata
          installed_package = _InstalledPackage(
              package=package,
              instalation_date=datetime.datetime.now(),
              hash=package_hash,
          )
          package_metadata = json.dumps(installed_package.to_json())
          (tmp_dir / _METADATA_FILENAME).write_text(package_metadata)
  
          # Rename the package to it's final destination
          installation_path = installed_package.installation_path
          if (
              installation_path.exists()
          ):  # Package already exists (with same hash)
              # In the future, we should be smarter to allow overwrite.
              raise ValueError(
                  f"Package {package} already installed in {installation_path}."
              )
          installation_path.parent.mkdir(parents=True, exist_ok=True)
          tmp_dir.rename(installation_path)
      finally:
          # Cleanup the tmp directory if it still exists.
          if tmp_dir.exists():
              tmp_dir.rmtree()
  
      return installed_package
  
imports: import collections
  import dataclasses
  import datetime
  import functools
  import hashlib
  import json
  import tempfile
  from typing import Any, Iterator, List, Optional, Type
  from absl import logging
  from etils import epath
  from tensorflow_datasets.core import dataset_builder
  from tensorflow_datasets.core import naming
  from tensorflow_datasets.core import registered
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.community import cache
  from tensorflow_datasets.core.community import dataset_sources
  from tensorflow_datasets.core.community import load
  from tensorflow_datasets.core.community import register_base
  from tensorflow_datasets.core.download import checksums
  from tensorflow_datasets.core.utils import gcs_utils
label_desc: Use image node_id 5 for calling a global function with example usage: _download_and_cache(package) and returns: installed_package