code: def load_checkpoint(
      model_type="original",
      checkpoint=None,
      device="cpu",
      huggingface_config_path=None,
  ):
      if checkpoint is None:
          checkpoint_path = MODEL_URLS[model_type]
          loaded = torch.hub.load_state_dict_from_url(
              checkpoint_path, map_location=device
          )
      else:
          loaded = torch.load(checkpoint, map_location=device)
          if "config" not in loaded or "state_dict" not in loaded:
              raise ValueError(
                  "Checkpoint needs to contain the config it was trained \
                      with as well as the state dict"
              )
      class_names = loaded["config"]["dataset"]["args"]["classes"]
      # standardise class names between models
      change_names = {
          "toxic": "toxicity",
          "identity_hate": "identity_attack",
          "severe_toxic": "severe_toxicity",
      }
      class_names = [change_names.get(cl, cl) for cl in class_names]
      model, tokenizer = get_model_and_tokenizer(
          **loaded["config"]["arch"]["args"],
          state_dict=loaded["state_dict"],
          huggingface_config_path=huggingface_config_path,
      )
  
      return model, tokenizer, class_names
  
file_path: detoxify/detoxify/detoxify.py
imports: import torch
  import transformers
label_desc: Use image node_id 2 for calling a global function with example usage: load_checkpoint(model_type, checkpoint, device, huggingface_config_path) and returns: model,  tokenizer,  class_names