code: def _get_last_installed_version(
      name: naming.DatasetName,
  ) -> Optional[_InstalledPackage]:
      """Checks whether the datasets is installed locally and returns it."""
      root_dir = (
          cache.module_path()
          / _IMPORT_MODULE_NAME
          / name.namespace
          / name.name
      )
      if not root_dir.exists():  # Dataset not found
          return None
  
      all_installed_package_metadatas = [
          package / _METADATA_FILENAME for package in root_dir.iterdir()
      ]
      all_installed_packages = [
          _InstalledPackage.from_json(json.loads(metadata.read_text()))
          for metadata in all_installed_package_metadatas
          if metadata.exists()
      ]
      all_installed_packages = sorted(
          all_installed_packages, key=lambda p: p.instalation_date
      )
  
      if not all_installed_packages:  # No valid package found
          return None
      else:
          return all_installed_packages[-1]
  
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 4 for calling a global function with example usage: _get_last_installed_version(name) and returns: None, None, all_installed_packages