code: def huggingface_from_pretrained(
      source: Union[Path, str], config: Dict
  ):
      """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'.
      config (dict): Settings to pass to the tokenizer.
      """
      warnings.warn(
          "spacy_transformers.util.huggingface_from_pretrained has been moved to "
          "spacy_transformers.layers.transformer_model.huggingface_from_pretrained "
          "with an updated API:\n"
          "huggingface_from_pretrained(source, tok_config, trf_config) -> HFObjects",
          DeprecationWarning,
      )
      if isinstance(source, Path):
          str_path = str(source.absolute())
      else:
          str_path = source
      tokenizer = AutoTokenizer.from_pretrained(str_path, **config)
      transformer = AutoModel.from_pretrained(str_path)
      torch_device = get_torch_default_device()
      transformer.to(torch_device)
      return tokenizer, transformer
  
imports: from typing import List, Dict, Union, Set
  from pathlib import Path
  import random
  from transformers import AutoModel, AutoTokenizer
  from transformers.tokenization_utils import BatchEncoding
  from transformers.tokenization_utils_fast import PreTrainedTokenizerFast
  import catalogue
  from spacy.util import registry
  from thinc.api import get_torch_default_device
  import torch.cuda
  import tempfile
  import shutil
  import contextlib
  import warnings
label_desc: Use image node_id 1 for calling a global function with example usage: huggingface_from_pretrained(source, config) and returns: tokenizer,  transformer