code: def _merge_lora(layer, name):
      if isinstance(
          layer, (bnb.nn.Linear4bit, peft.tuners.lora.Linear4bit)
      ):
          # Is LoRA so we need to merge!
          W, quant_state, A, B, s = get_lora_parameters(layer)
          dtype = (
              quant_state.dtype
              if type(quant_state) is not list
              else quant_state[2]
          )
          W = fast_dequantize(W, quant_state).to(torch.float32).t()
          sAB = A.t().to(torch.float32) @ (s * B.t().to(torch.float32))
          W += sAB
          if not torch.isfinite(W).all():
              raise ValueError(
                  f"Unsloth: Merge failed.\n{name} has some elements = infinity."
              )
          W = W.t().to(dtype)
      else:
          W = layer.weight
      return W
  
file_path: unsloth/unsloth/save.py
imports: from peft import PeftModelForCausalLM
  from collections import OrderedDict
  import bitsandbytes
  import peft
  import gc
  import os
  from tqdm import tqdm
  import shutil
  from typing import Optional, Callable, Union
  import torch
  from transformers.models.llama.modeling_llama import logger
  from .kernels import fast_dequantize, QUANT_STATE, get_lora_parameters
label_desc: Use image node_id 1 for calling a global function with example usage: _merge_lora(layer, name) and returns: W