code: def check_hash(
      filepath: PathLike, val: str | None = None, hash_type: str = "md5"
  ) -> bool:
      """
      Verify hash signature of specified file.
  
      Args:
          filepath: path of source file to verify hash value.
          val: expected hash value of the file.
          hash_type: type of hash algorithm to use, default is `"md5"`.
              The supported hash types are `"md5"`, `"sha1"`, `"sha256"`, `"sha512"`.
              See also: :py:data:`monai.apps.utils.SUPPORTED_HASH_TYPES`.
  
      """
      if val is None:
          logger.info(
              f"Expected {hash_type} is None, skip {hash_type} check for file {filepath}."
          )
          return True
      actual_hash_func = look_up_option(
          hash_type.lower(), SUPPORTED_HASH_TYPES
      )
      actual_hash = actual_hash_func()
      try:
          with open(filepath, "rb") as f:
              for chunk in iter(lambda: f.read(1024 * 1024), b""):
                  actual_hash.update(chunk)
      except Exception as e:
          logger.error(f"Exception in check_hash: {e}")
          return False
      if val != actual_hash.hexdigest():
          logger.error(f"check_hash failed {actual_hash.hexdigest()}.")
          return False
  
      logger.info(
          f"Verified '{_basename(filepath)}', {hash_type}: {val}."
      )
      return True
  
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 4 for calling a global function with example usage: check_hash(filepath, val, hash_type) and returns: True, True, False, False