class_docstr: Handles the `task name -> model class` and `architecture -> configuration` mappings.
code: def get_model_files(
      model_name_or_path: Union[str, Path],
      subfolder: str = "",
      cache_dir: str = huggingface_hub.constants.HUGGINGFACE_HUB_CACHE,
  ):
      request_exception = None
      full_model_path = Path(model_name_or_path) / subfolder
      if full_model_path.is_dir():
          all_files = [
              os.path.relpath(
                  os.path.join(dirpath, file), full_model_path
              )
              for dirpath, _, filenames in os.walk(full_model_path)
              for file in filenames
          ]
      else:
          try:
              if not isinstance(model_name_or_path, str):
                  model_name_or_path = str(model_name_or_path)
              all_files = huggingface_hub.list_repo_files(
                  model_name_or_path, repo_type="model"
              )
              if subfolder != "":
                  all_files = [
                      file[len(subfolder) + 1 :]
                      for file in all_files
                      if file.startswith(subfolder)
                  ]
          except RequestsConnectionError as e:  # Hub not accessible
              request_exception = e
              object_id = model_name_or_path.replace("/", "--")
              full_model_path = Path(cache_dir, f"models--{object_id}")
              if full_model_path.is_dir():  # explore the cache first
                  # Resolve refs (for instance to convert main to the associated commit sha)
                  revision_file = Path(full_model_path, "refs", "main")
                  revision = ""
                  if revision_file.is_file():
                      with open(revision_file) as f:
                          revision = f.read()
                  cached_path = Path(
                      full_model_path, "snapshots", revision, subfolder
                  )
                  all_files = [
                      os.path.relpath(
                          os.path.join(dirpath, file), cached_path
                      )
                      for dirpath, _, filenames in os.walk(cached_path)
                      for file in filenames
                  ]
  
      return all_files, request_exception
  
imports: import importlib
  import inspect
  import itertools
  import json
  import os
  from functools import partial
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple, Type, Union
  import huggingface_hub
  from packaging import version
  from requests.exceptions import ConnectionError
  from transformers import AutoConfig, PretrainedConfig, is_tf_available, is_torch_available
  from transformers.utils import SAFE_WEIGHTS_NAME, TF2_WEIGHTS_NAME, WEIGHTS_NAME, logging
  from ..utils import CONFIG_NAME
  from ..utils.import_utils import is_onnx_available
label_desc: Use image node_id 8 for calling the TasksManager obj's underlying member method code with example usage: obj.get_model_files(model_name_or_path, subfolder, cache_dir) and returns: all_files,  request_exception