code: def _fetch_from_remote(url, force_download=False):
      import tempfile, requests, tarfile
  
      cached_dir = os.path.join(MODULE_HOME, "ernie_for_gen")
      if force_download or not os.path.exists(cached_dir):
          with tempfile.NamedTemporaryFile() as f:
              # url = 'https://ernie.bj.bcebos.com/ERNIE_stable.tgz'
              r = requests.get(url, stream=True)
              total_len = int(r.headers.get("content-length"))
              for chunk in tqdm(
                  r.iter_content(chunk_size=1024),
                  total=total_len // 1024,
                  desc="downloading %s" % url,
                  unit="KB",
              ):
                  if chunk:
                      f.write(chunk)
                      f.flush()
              logger.debug("extacting... to %s" % f.name)
              with tarfile.open(f.name) as tf:
  
                  def is_within_directory(directory, target):
                      abs_directory = os.path.abspath(directory)
                      abs_target = os.path.abspath(target)
  
                      prefix = os.path.commonprefix(
                          [abs_directory, abs_target]
                      )
  
                      return prefix == abs_directory
  
                  def safe_extract(
                      tar,
                      path=".",
                      members=None,
                      *,
                      numeric_owner=False,
                  ):
                      for member in tar.getmembers():
                          member_path = os.path.join(path, member.name)
                          if not is_within_directory(path, member_path):
                              raise Exception(
                                  "Attempted Path Traversal in Tar File"
                              )
  
                      tar.extractall(
                          path, members, numeric_owner=numeric_owner
                      )
  
                  safe_extract(tf, path=cached_dir)
      logger.debug("%s cached in %s" % (url, cached_dir))
      return cached_dir
  
imports: import os
  from tqdm import tqdm
  from paddlehub.common.logger import logger
  from paddlehub.common.dir import MODULE_HOME
label_desc: Use image node_id 1 for calling a global function with example usage: _fetch_from_remote(url, force_download) and returns: cached_dir, unknown