code: def huggingface_from_pretrained(
      source: Union[Path, str],
      tok_config: Dict,
      trf_config: Dict,
      config_cls=AutoConfig,
      model_cls=AutoModel,
      tokenizer_cls=AutoTokenizer,
  ) -> HFObjects:
      """Create a Huggingface transformer model from pretrained weights. Will
      download the model if it is not already downloaded.
  
      source (Union[str, Path]): The name of the model or a path to it, such as
          'bert-base-cased'.
      tok_config (dict): Settings to pass to the tokenizer.
      trf_config (dict): Settings to pass to the transformer.
      """
      if isinstance(source, Path):
          str_path = str(source.absolute())
      else:
          str_path = source
      tokenizer = tokenizer_cls.from_pretrained(str_path, **tok_config)
      vocab_file_contents = None
      if hasattr(tokenizer, "vocab_file"):
          with open(tokenizer.vocab_file, "rb") as fileh:
              vocab_file_contents = fileh.read()
      trf_config["return_dict"] = True
      config = config_cls.from_pretrained(str_path, **trf_config)
      transformer = model_cls.from_pretrained(str_path, config=config)
      torch_device = get_torch_default_device()
      transformer.to(torch_device)
      return HFObjects(tokenizer, transformer, vocab_file_contents)
  
imports: from typing import List, Tuple, Callable, Union, Dict
  import copy
  from pathlib import Path
  from transformers.file_utils import ModelOutput
  from transformers import AutoConfig, AutoModel, AutoTokenizer
  from transformers.tokenization_utils_fast import PreTrainedTokenizerFast
  from transformers.tokenization_utils import BatchEncoding
  from spacy.tokens import Doc
  from thinc.api import Model, get_torch_default_device, xp2torch
  from thinc.types import ArgsKwargs
  import logging
  from ..data_classes import FullTransformerBatch, WordpieceBatch, HFObjects
  from ..util import maybe_flush_pytorch_cache
  from ..util import log_gpu_memory, log_batch_size
  from ..layers._util import replace_listener, replace_listener_cfg
  from ..truncate import truncate_oversize_splits
  from ..align import get_alignment, get_alignment_via_offset_mapping
  from .hf_wrapper import HFWrapper
label_desc: Use image node_id 7 for calling a global function with example usage: huggingface_from_pretrained(source, tok_config, trf_config, config_cls, model_cls, tokenizer_cls) and returns: HFObjects