code: def extractall(
      filepath: PathLike,
      output_dir: PathLike = ".",
      hash_val: str | None = None,
      hash_type: str = "md5",
      file_type: str = "",
      has_base: bool = True,
  ) -> None:
      """
      Extract file to the output directory.
      Expected file types are: `zip`, `tar.gz` and `tar`.
  
      Args:
          filepath: the file path of compressed file.
          output_dir: target directory to save extracted files.
          hash_val: expected hash value to validate the compressed file.
              if None, skip hash validation.
          hash_type: 'md5' or 'sha1', defaults to 'md5'.
          file_type: string of file type for decompressing. Leave it empty to infer the type from the filepath basename.
          has_base: whether the extracted files have a base folder. This flag is used when checking if the existing
              folder is a result of `extractall`, if it is, the extraction is skipped. For example, if A.zip is unzipped
              to folder structure `A/*.png`, this flag should be True; if B.zip is unzipped to `*.png`, this flag should
              be False.
  
      Raises:
          RuntimeError: When the hash validation of the ``filepath`` compressed file fails.
          NotImplementedError: When the ``filepath`` file extension is not one of [zip", "tar.gz", "tar"].
  
      """
      if has_base:
          # the extracted files will be in this folder
          cache_dir = Path(
              output_dir, _basename(filepath).split(".")[0]
          )
      else:
          cache_dir = Path(output_dir)
      if (
          cache_dir.exists()
          and next(cache_dir.iterdir(), None) is not None
      ):
          logger.info(
              f"Non-empty folder exists in {cache_dir}, skipped extracting."
          )
          return
      filepath = Path(filepath)
      if hash_val and not check_hash(filepath, hash_val, hash_type):
          raise RuntimeError(
              f"{hash_type} check of compressed file failed: "
              f"filepath={filepath}, expected {hash_type}={hash_val}."
          )
      logger.info(f"Writing into directory: {output_dir}.")
      _file_type = file_type.lower().strip()
      if filepath.name.endswith("zip") or _file_type == "zip":
          zip_file = zipfile.ZipFile(filepath)
          zip_file.extractall(output_dir)
          zip_file.close()
          return
      if (
          filepath.name.endswith("tar")
          or filepath.name.endswith("tar.gz")
          or "tar" in _file_type
      ):
          tar_file = tarfile.open(filepath)
          tar_file.extractall(output_dir)
          tar_file.close()
          return
      raise NotImplementedError(
          f'Unsupported file type, available options are: ["zip", "tar.gz", "tar"]. name={filepath} type={file_type}.'
      )
  
imports: from __future__ import annotations
  import hashlib
  import json
  import logging
  import os
  import shutil
  import sys
  import tarfile
  import tempfile
  import warnings
  import zipfile
  from pathlib import Path
  from typing import TYPE_CHECKING, Any
  from urllib.error import ContentTooShortError, HTTPError, URLError
  from urllib.parse import urlparse
  from urllib.request import urlopen, urlretrieve
  from monai.config.type_definitions import PathLike
  from monai.utils import look_up_option, min_version, optional_import
label_desc: Use image node_id 6 for calling a global function with example usage: extractall(filepath, output_dir, hash_val, hash_type, file_type, has_base) without return types