code: def download_cached(
      url,
      checksum=None,
      checksum_algo="sha1",
      cache_dir=None,
      force_extract=False,
      **kwargs,
  ):
      if isinstance(url, Path):
          url = str(url)
  
      if is_remote_url(url):
          output_path = get_from_cache(
              url, cache_dir=cache_dir, **kwargs
          )
      else:
          raise ValueError("Unable to parse '{}' as a URL".format(url))
  
      if not output_path:
          return None
  
      # if checksum is given, verify it
      if checksum and checksum_algo:
          h = hashlib.new(checksum_algo)
          with open(output_path, "rb") as f:
              h.update(f.read())
          calculated_checksum = h.hexdigest()
          if calculated_checksum != checksum.lower():
              raise EnvironmentError(
                  "Failed to verify checksum of '{}'".format(
                      output_path
                  )
              )
  
      if not is_zipfile(output_path) and not tarfile.is_tarfile(
          output_path
      ):
          return output_path
  
      # Path where we extract compressed archives
      # We avoid '.' in dir name and add "-extracted" at the end: "./model.zip" => "./model-zip-extracted/"
      output_dir, output_file = os.path.split(output_path)
      output_extract_dir_name = (
          output_file.replace(".", "-") + "-extracted"
      )
      output_path_extracted = os.path.join(
          output_dir, output_extract_dir_name
      )
  
      if (
          os.path.isdir(output_path_extracted)
          and os.listdir(output_path_extracted)
          and not force_extract
      ):
          return output_path_extracted
  
      # Prevent parallel extractions
      lock_path = output_path + ".lock"
      with FileLock(lock_path):
          shutil.rmtree(output_path_extracted, ignore_errors=True)
          os.makedirs(output_path_extracted)
          if is_zipfile(output_path):
              with ZipFile(output_path, "r") as zip_file:
                  # we want to extract all files into a flat folder structure (i.e. no subfolders)
                  for file in zip_file.namelist():
                      # check if we have a valid file
                      if basename(file):
                          file_data = zip_file.read(file)
                          with open(
                              join(
                                  output_path_extracted, basename(file)
                              ),
                              "wb",
                          ) as f:
                              f.write(file_data)
          elif tarfile.is_tarfile(output_path):
              tar_file = tarfile.open(output_path)
              tar_file.extractall(output_path_extracted)
              tar_file.close()
          else:
              raise EnvironmentError(
                  "Archive format of {} could not be identified".format(
                      output_path
                  )
              )
  
      return output_path_extracted
  
imports: import ast
  import fnmatch
  import hashlib
  import inspect
  import io
  import json
  import logging
  import os
  import re
  import shutil
  import tarfile
  import tempfile
  from collections.abc import Mapping
  from contextlib import contextmanager
  from dataclasses import dataclass
  from enum import Enum
  from functools import partial
  from os.path import basename, isdir, isfile, join
  from pathlib import Path
  from typing import Callable, Dict, List, Optional, Tuple, Union
  from urllib.parse import urlparse
  from zipfile import ZipFile, is_zipfile
  import torch
  import requests
  from filelock import FileLock
  from huggingface_hub import HfApi, HfFolder, snapshot_download
  from huggingface_hub.file_download import http_get, url_to_filename
  from huggingface_hub.utils import EntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError, hf_raise_for_status
  from requests.exceptions import HTTPError
  from transformers.utils import http_user_agent, is_remote_url
  from transformers.utils.hub import torch_cache_home
  from .None import __version__
  from .context import ForwardContext
label_desc: Use image node_id 7 for calling a global function with example usage: download_cached(url, checksum, checksum_algo, cache_dir, force_extract) and returns: output_path_extracted, None, output_path, output_path_extracted