docstr: Fetch the checkpoint files from the HuggingFace Hub.
code: def _fetch_checkpoint_files(self):
      """
      Fetch the checkpoint files from the HuggingFace Hub.
      """
      # TODO(jeff): for models like llama-2 the user will have to provide an auth `token`,
      # currently coming from the ckpt engine init but maybe a catch all kwargs for other
      # snapshot download parameters would be more flexible.
  
      # NOTE(jeff): allow_patterns here are explicitly not using safetensors or other
      # checkpoint files that may be present. Example of all files in the llama-2-7b
      # repo here: https://huggingface.co/meta-llama/Llama-2-7b-hf/tree/main
      from huggingface_hub import snapshot_download, list_files_info
  
      def model_has_safetensors(model_name_or_path: str) -> bool:
          if os.path.isdir(model_name_or_path):
              file_list = os.listdir(model_name_or_path)
          else:
              file_list = [
                  rf.rfilename
                  for rf in list_files_info(model_name_or_path)
              ]
          for f in file_list:
              if f.endswith(".safetensors"):
                  return True
          return False
  
      if os.path.isdir(self.model_name_or_path):
          self._local_checkpoint_dir = self.model_name_or_path
      else:
          # We need to download the checkpoint files from HF
          if model_has_safetensors(self.model_name_or_path):
              # Prioritize downloading safetensors if they are available
              allow_patterns = ["*.safetensors", "*.json"]
          else:
              # Fallback to bin files when safetensors are not present
              allow_patterns = ["*.bin", "*.json", "*.pt"]
          self._local_checkpoint_dir = snapshot_download(
              self.model_name_or_path,
              allow_patterns=allow_patterns,
              revision=None,
              token=self.auth_token,
          )
  
      assert os.path.isdir(
          self._local_checkpoint_dir
      ), f"Checkpoint dir {self._local_checkpoint_dir} is not a directory, cannot load checkpoint."
  
      # Set the appropriate file names based on whether we have safetensors or not
      if model_has_safetensors(self._local_checkpoint_dir):
          from safetensors.torch import load_file
  
          model_param_json_fname = "model.safetensors.index.json"
          model_file_fname = "model.safetensors"
          self._checkpoint_load_fn = load_file
      else:
          model_param_json_fname = "pytorch_model.bin.index.json"
          model_file_fname = "pytorch_model.bin"
          self._checkpoint_load_fn = partial(
              torch.load, map_location="cpu"
          )
  
      model_param_json = os.path.join(
          self._local_checkpoint_dir, model_param_json_fname
      )
  
      if not os.path.isfile(model_param_json):
          # We don't need any json as all such HF models will have pytorch_model.bin
          all_checkpoint_files = [
              os.path.join(self._local_checkpoint_dir, model_file_fname)
          ]
      else:
          param_map = json.load(open(model_param_json, "r"))
  
          # weight_map -> { "lm_head.weight": "pytorch_model-00002-of-00002.bin", ... }
          weight_map = param_map["weight_map"]
  
          # unique set of all checkpoint files
          all_checkpoint_files = set(weight_map.values())
  
          # get absolute path of all unique checkpoint files
          all_checkpoint_files = [
              os.path.join(self._local_checkpoint_dir, f)
              for f in all_checkpoint_files
          ]
  
      return all_checkpoint_files
  
file_path: deepspeed/deepspeed/inference/v2/checkpoint/huggingface_engine.py
imports: import os
  import json
  import torch
  from .base_engine import CheckpointEngineBase
  from typing import Iterable, Tuple
  from functools import partial
  from ..logging import inference_logger
label_desc: Use image node_id 2 for calling the HuggingFaceCheckpointEngine obj's underlying member method code with example usage: obj._fetch_checkpoint_files() and returns: all_checkpoint_files, False, True