code: def cache_url(url: str, cache_dir: str) -> str:
      """
      This implementation downloads the remote resource and caches it locally.
      The resource will only be downloaded if not previously requested.
      """
      parsed_url = urlparse(url)
      dirname = os.path.join(
          cache_dir, os.path.dirname(parsed_url.path.lstrip("/"))
      )
      makedir(dirname)
      filename = url.split("/")[-1]
      cached = os.path.join(dirname, filename)
      with file_lock(cached):
          if not os.path.isfile(cached):
              logging.info(f"Downloading {url} to {cached} ...")
              cached = download(url, dirname, filename=filename)
      logging.info(f"URL {url} cached in {cached}")
      return cached
  
imports: import json
  import logging
  import os
  import pickle
  import re
  import shutil
  import time
  from urllib.parse import urlparse
  import numpy
  import pandas
  import yaml
  from iopath.common.download import download
  from iopath.common.file_io import file_lock, g_pathmgr
  from vissl.utils.slurm import get_slurm_dir
label_desc: Use image node_id 1 for calling a global function with example usage: cache_url(url, cache_dir) and returns: cached