code: def weight_files(
      model_id: str,
      revision: Optional[str] = None,
      extension: str = ".safetensors",
  ) -> List[Path]:
      """Get the local files"""
      # Local model
      d = Path(model_id)
      if d.exists() and d.is_dir():
          local_files = _weight_files_from_dir(d, extension)
          if not local_files:
              raise FileNotFoundError(
                  f"No local weights found in {model_id} with extension {extension}"
              )
          return [Path(f) for f in local_files]
  
      try:
          filenames = weight_hub_files(model_id, revision, extension)
      except EntryNotFoundError as e:
          if extension != ".safetensors":
              raise e
          # Try to see if there are pytorch weights
          pt_filenames = weight_hub_files(
              model_id, revision, extension=".bin"
          )
          # Change pytorch extension to safetensors extension
          # It is possible that we have safetensors weights locally even though they are not on the
          # hub if we converted weights locally without pushing them
          filenames = [
              f"{Path(f).stem.lstrip('pytorch_')}.safetensors"
              for f in pt_filenames
          ]
  
      if WEIGHTS_CACHE_OVERRIDE is not None:
          files = []
          for filename in filenames:
              p = Path(WEIGHTS_CACHE_OVERRIDE) / filename
              if not p.exists():
                  raise FileNotFoundError(
                      f"File {p} not found in {WEIGHTS_CACHE_OVERRIDE}."
                  )
              files.append(p)
          return files
  
      files = []
      for filename in filenames:
          cache_file = try_to_load_from_cache(
              model_id, revision=revision, filename=filename
          )
          if cache_file is None:
              raise LocalEntryNotFoundError(
                  f"File {filename} of model {model_id} not found in "
                  f"{os.getenv('HUGGINGFACE_HUB_CACHE', 'the local cache')}. "
                  f"Please run `text-generation-server download-weights {model_id}` first."
              )
          files.append(cache_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 7 for calling a global function with example usage: weight_files(model_id, revision, extension) and returns: files, unknown, files