code: def _load_pretrained_hf_model_from_dir(
      model_class: Type,
      pretrained_model_name_or_path: Optional[Union[str, PathLike]],
      **pretrained_kwargs,
  ) -> PreTrainedModel:
      """Downloads a model to a local temporary directory, and Loads a pretrained HF model from a local directory."""
      with tempfile.TemporaryDirectory() as tmpdir:
          download(pretrained_model_name_or_path, tmpdir)
          return model_class.from_pretrained(
              tmpdir, **pretrained_kwargs
          )
  
file_path: ludwig/ludwig/utils/hf_utils.py
imports: import logging
  import os
  import tempfile
  from os import PathLike
  from typing import Optional, Tuple, Type, Union
  from transformers import AutoTokenizer, PreTrainedModel
  from transformers.tokenization_utils import PreTrainedTokenizer
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.utils.error_handling_utils import default_retry
  from ludwig.utils.fs_utils import download, path_exists
  from ludwig.utils.upload_utils import hf_hub_login
label_desc: Use image node_id 3 for calling a global function with example usage: _load_pretrained_hf_model_from_dir(model_class, pretrained_model_name_or_path) and returns: model_class