code: def get_checkpoint_shard_files(
      pretrained_model_name_or_path,
      index_filename,
      cache_dir=None,
      force_download=False,
      proxies=None,
      resume_download=False,
      local_files_only=False,
      use_auth_token=None,
      user_agent=None,
      revision=None,
      subfolder="",
      _commit_hash=None,
  ):
      """
      For a given model:
  
      - download and cache all the shards of a sharded checkpoint if `pretrained_model_name_or_path` is a model ID on the
        Hub
      - returns the list of paths to all the shards, as well as some metadata.
  
      For the description of each arg, see [`PreTrainedModel.from_pretrained`]. `index_filename` is the full path to the
      index (downloaded and cached if `pretrained_model_name_or_path` is a model ID on the Hub).
      """
      import json
  
      if not os.path.isfile(index_filename):
          raise ValueError(
              f"Can't find a checkpoint index ({index_filename}) in {pretrained_model_name_or_path}."
          )
  
      with open(index_filename, "r") as f:
          index = json.loads(f.read())
  
      shard_filenames = sorted(list(set(index["weight_map"].values())))
      sharded_metadata = index["metadata"]
      sharded_metadata["all_checkpoint_keys"] = list(
          index["weight_map"].keys()
      )
  
      # First, let's deal with local folder.
      if os.path.isdir(pretrained_model_name_or_path):
          shard_filenames = [
              os.path.join(pretrained_model_name_or_path, subfolder, f)
              for f in shard_filenames
          ]
          return shard_filenames, sharded_metadata
  
      # At this stage pretrained_model_name_or_path is a model identifier on the Hub
      cached_filenames = []
      for shard_filename in shard_filenames:
          try:
              # Load from URL
              cached_filename = cached_file(
                  pretrained_model_name_or_path,
                  shard_filename,
                  cache_dir=cache_dir,
                  force_download=force_download,
                  proxies=proxies,
                  resume_download=resume_download,
                  local_files_only=local_files_only,
                  use_auth_token=use_auth_token,
                  user_agent=user_agent,
                  revision=revision,
                  subfolder=subfolder,
                  _commit_hash=_commit_hash,
              )
          # We have already dealt with RepositoryNotFoundError and RevisionNotFoundError when getting the index, so
          # we don't have to catch them here.
          except EntryNotFoundError:
              raise EnvironmentError(
                  f"{pretrained_model_name_or_path} does not appear to have a file named {shard_filename} which is "
                  "required according to the checkpoint index."
              )
          except HTTPError:
              raise EnvironmentError(
                  f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load {shard_filename}. You should try"
                  " again after checking your internet connection."
              )
  
          cached_filenames.append(cached_filename)
  
      return cached_filenames, sharded_metadata
  
imports: import json
  import os
  import re
  import shutil
  import sys
  import tempfile
  import traceback
  import warnings
  from pathlib import Path
  from typing import Dict, List, Optional, Tuple, Union
  from urllib.parse import urlparse
  from uuid import uuid4
  import huggingface_hub
  import requests
  from huggingface_hub import CommitOperationAdd, HfFolder, create_commit, create_repo, get_hf_file_metadata, hf_hub_download, hf_hub_url, whoami
  from huggingface_hub.file_download import REGEX_COMMIT_HASH, http_get
  from huggingface_hub.utils import EntryNotFoundError, LocalEntryNotFoundError, RepositoryNotFoundError, RevisionNotFoundError, hf_raise_for_status
  from requests.exceptions import HTTPError
  from transformers.utils.logging import tqdm
  from .None import __version__, logging
  from .generic import working_or_temp_dir
  from .import_utils import ENV_VARS_TRUE_VALUES, _tf_version, _torch_version, is_tf_available, is_torch_available, is_training_run_on_sagemaker
label_desc: Use image node_id 15 for calling a global function with example usage: get_checkpoint_shard_files(pretrained_model_name_or_path, index_filename, cache_dir, force_download, proxies, resume_download, local_files_only, use_auth_token, user_agent, revision, subfolder, _commit_hash) and returns: cached_filenames,  sharded_metadata, shard_filenames,  sharded_metadata