code: def download(url, dir, unzip=True, delete=False, threads=1):
      def download_one(url, dir):
          f = dir / Path(url).name
          if Path(url).is_file():
              Path(url).rename(f)
          elif not f.exists():
              print(f"Downloading {url} to {f}")
              torch.hub.download_url_to_file(url, f, progress=True)
          if unzip and f.suffix in (".zip", ".tar"):
              print(f"Unzipping {f.name}")
              if f.suffix == ".zip":
                  ZipFile(f).extractall(path=dir)
              elif f.suffix == ".tar":
                  TarFile(f).extractall(path=dir)
              if delete:
                  f.unlink()
                  print(f"Delete {f}")
  
      dir = Path(dir)
      if threads > 1:
          pool = ThreadPool(threads)
          pool.imap(lambda x: download_one(*x), zip(url, repeat(dir)))
          pool.close()
          pool.join()
      else:
          for u in [url] if isinstance(url, (str, Path)) else url:
              download_one(u, dir)
  
file_path: mmdetection/tools/misc/download_dataset.py
imports: import argparse
  import tarfile
  from itertools import repeat
  from multiprocessing.pool import ThreadPool
  from pathlib import Path
  from tarfile import TarFile
  from zipfile import ZipFile
  import torch
  from mmengine.utils.path import mkdir_or_exist
label_desc: Use image node_id 2 for calling a global function with example usage: download(url, dir, unzip, delete, threads) without return types