code: def update_weights(
      target: peft.tuners.lora.LoraLayer,
      new_weight: torch.Tensor,
      reinit: bool,
      device,
  ):
      if reinit:
          for adapter_name in target.lora_A:
              target.reset_lora_parameters(adapter_name)
          for adapter_name in target.lora_embedding_A:
              target.reset_lora_parameters(adapter_name)
  
      if isinstance(target, peft.tuners.lora.Linear4bit):
          # This could be faster, but the quantization of Linear4bit weights occurs
          # when the module is moved from cpu to gpu. Without meddling *too* deeply in
          # PEFT's innards or maintaining a duplicate of that codepath, this is good
          # enough for now.
          target.weight.quant_state = None
          target.weight.data = new_weight.cpu()
          target.to(device)
      elif isinstance(target, peft.tuners.lora.Linear8bitLt):
          target.weight = bnb.nn.Int8Params(
              new_weight, requires_grad=False
          ).to(device)
      else:
          target.weight.data = new_weight.to(device)
  
imports: import glob
  import json
  import logging
  import os.path
  import shutil
  from pathlib import Path
  from typing import Dict, List, Sequence
  import bitsandbytes
  import peft
  import safetensors.torch
  import torch
  from huggingface_hub import snapshot_download
  from torch.optim.lr_scheduler import LRScheduler
  from torch.optim.optimizer import Optimizer
  from transformers import TrainerCallback, TrainerControl, TrainerState, TrainingArguments
  from transformers.trainer_utils import PREFIX_CHECKPOINT_DIR
  from axolotl.utils.dict import DictDefault
  from axolotl.utils.distributed import is_main_process
label_desc: Use image node_id 5 for calling a global function with example usage: update_weights(target, new_weight, reinit, device) without return types