code: def _download_weight(url):
      weight_dir = os.path.expanduser("~/.cache/paddle/weights")
      os.makedirs(weight_dir, exist_ok=True)
      filename = os.path.basename(urlparse(url).path)
      base, ext = os.path.splitext(filename)
      assert ext in [".tar", ".pdparams"], "Unsupported weight format"
      if ext == ".tar":
          dest = os.path.join(weight_dir, base)
          if os.path.exists(dest):
              assert os.path.isdir(
                  dest
              ), "weight path is not a directory"
              return dest
      else:
          dest = os.path.join(weight_dir, filename)
          if os.path.isfile(dest):
              return dest
  
      print("downloading {}".format(url))
  
      req = urlopen(url)
      total = float(req.headers["content-length"])
      tmp = tempfile.NamedTemporaryFile(delete=False)
      downloaded = 0
  
      try:
          while True:
              buffer = req.read(8192)
              if len(buffer) == 0:
                  break
              tmp.write(buffer)
              downloaded += len(buffer)
              sys.stdout.write(
                  "\r{0:.1f}%".format(100 * downloaded / total)
              )
              sys.stdout.flush()
  
          sys.stdout.write("\n")
          tmp.close()
          if ext == ".tar":
              _extract_tar(tmp.name, weight_dir)
          else:
              shutil.move(tmp.name, dest)
      finally:
          tmp.close()
          if os.path.exists(tmp.name):
              os.remove(tmp.name)
  
      return dest
  
file_path: DALI/docs/examples/use_cases/paddle/tsm/utils.py
imports: import errno
  import os
  import shutil
  import sys
  import tarfile
  import tempfile
  import paddle
label_desc: Use image node_id 2 for calling a global function with example usage: _download_weight(url) and returns: dest, dest, dest