code: def load_cfg_model_tokenizer(
      experiment_path: str, merge: bool = False, device: str = "cuda:0"
  ):
      cfg = load_config_yaml(os.path.join(experiment_path, "cfg.yaml"))
      cfg.architecture.pretrained = False
      cfg.architecture.gradient_checkpointing = False
      cfg.environment._device = device.replace("_shard", "")
      cfg.environment._local_rank = 0
      cfg.prediction._visibility["num_history"] = 1
  
      tokenizer = get_tokenizer(cfg)
  
      gc.collect()
      torch.cuda.empty_cache()
  
      if (
          merge
          and cfg.training.lora
          and cfg.architecture.backbone_dtype in ("int4", "int8")
      ):
          logger.info(
              "Loading backbone in float16 for merging LORA weights."
          )
          cfg.architecture.backbone_dtype = "float16"
          cfg.architecture.pretrained = True
  
      with torch.device(cfg.environment._device):
          model = cfg.architecture.model_class(cfg)
          cfg.architecture.pretrained_weights = os.path.join(
              experiment_path, "checkpoint.pth"
          )
          load_checkpoint(cfg, model, strict=False)
  
      if merge and cfg.training.lora:
          # merges the LoRa layers into the base model.
          # This is needed if one wants to use the base model as a standalone model.
          logger.info("Merging LORA layers with base model.")
          model.backbone = model.backbone.merge_and_unload()
  
      if device == "cpu_shard":
          max_memory = get_balanced_memory(
              model,
          )
          device_map = infer_auto_device_map(
              model, max_memory=max_memory
          )
          model = dispatch_model(
              model,
              device_map=device_map,
          )
  
      model = model.eval()
      model.backbone.use_cache = True
  
      return cfg, model, tokenizer
  
imports: import asyncio
  import gc
  import logging
  import os
  import threading
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  import torch
  from accelerate import dispatch_model, infer_auto_device_map
  from accelerate.utils import get_balanced_memory
  from h2o_wave import Q
  from h2o_wave import data
  from h2o_wave import ui
  from transformers import AutoTokenizer, TextStreamer
  from llm_studio.app_utils.utils import get_experiments, get_ui_elements, parse_ui_elements, set_env
  from llm_studio.python_configs.base import DefaultConfigProblemBase
  from llm_studio.src.datasets.text_utils import get_tokenizer
  from llm_studio.src.models.text_causal_language_modeling_model import Model
  from llm_studio.src.utils.config_utils import NON_GENERATION_PROBLEM_TYPES, load_config_yaml
  from llm_studio.src.utils.modeling_utils import load_checkpoint
label_desc: Use image node_id 3 for calling a global function with example usage: load_cfg_model_tokenizer(experiment_path, merge, device) and returns: cfg,  model,  tokenizer