code: def download_weights(
      filenames: List[str],
      model_id: str,
      revision: Optional[str] = None,
  ) -> List[Path]:
      """Download the safetensors files from the hub"""
  
      def download_file(fname, tries=5, backoff: int = 5):
          local_file = try_to_load_from_cache(model_id, revision, fname)
          if local_file is not None:
              logger.info(f"File {fname} already present in cache.")
              return Path(local_file)
  
          for idx in range(tries):
              try:
                  logger.info(f"Download file: {fname}")
                  stime = time.time()
                  local_file = hf_hub_download(
                      filename=fname,
                      repo_id=model_id,
                      revision=revision,
                      local_files_only=HF_HUB_OFFLINE,
                  )
                  logger.info(
                      f"Downloaded {local_file} in {timedelta(seconds=int(time.time() - stime))}."
                  )
                  return Path(local_file)
              except Exception as e:
                  if idx + 1 == tries:
                      raise e
                  logger.error(e)
                  logger.info(f"Retrying in {backoff} seconds")
                  time.sleep(backoff)
                  logger.info(f"Retry {idx + 1}/{tries - 1}")
  
      # We do this instead of using tqdm because we want to parse the logs with the launcher
      start_time = time.time()
      files = []
      for i, filename in enumerate(filenames):
          file = download_file(filename)
  
          elapsed = timedelta(seconds=int(time.time() - start_time))
          remaining = len(filenames) - (i + 1)
          eta = (elapsed / (i + 1)) * remaining if remaining > 0 else 0
  
          logger.info(
              f"Download: [{i + 1}/{len(filenames)}] -- ETA: {eta}"
          )
          files.append(file)
  
      return files
  
file_path: text-generation-inference/server/text_generation_server/utils/hub.py
imports: import time
  import os
  from datetime import timedelta
  from loguru import logger
  from pathlib import Path
  from typing import Optional, List
  from huggingface_hub import file_download, hf_api, HfApi, hf_hub_download
  from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE
  from huggingface_hub.utils import LocalEntryNotFoundError, EntryNotFoundError, RevisionNotFoundError
label_desc: Use image node_id 8 for calling a global function with example usage: download_weights(filenames, model_id, revision) and returns: files, Path, Path