class_docstr: Callback to merge LoRA weights into the base model and save full-weight checkpoints
class_docstr_tok: ["Callback","to","merge","LoRA","weights","into","the","base","model","and","save","full-weight","checkpoints"]
code: def on_train_begin(
      self,
      _args: TrainingArguments,
      _state: TrainerState,
      control: TrainerControl,
      model: peft.LoraModel,
      **_kwargs,
  ):
      if self.resume_from_checkpoint:
          weight_path = os.path.join(
              self.resume_from_checkpoint, "relora"
          )
          if not os.path.exists(weight_path):
              LOG.warning(
                  "Resuming ReLoRA from checkpoint, but no full-weight save found"
              )
          else:
              LOG.info(
                  f"Loading adjusted base weights from {weight_path}"
              )
              load_weight_checkpoint(model, weight_path)
      return control
  
imports: from typing import Optional
  import torch
  from transformers.trainer import Trainer
  import glob
  import json
  import logging
  import os.path
  import shutil
  from pathlib import Path
  from typing import Dict, List, Sequence
  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
  import torch.distributed
  from bigdl.llm.transformers.qlora import LoraLowBitLinear
  from bigdl.llm.transformers.low_bit_linear import FP4Params
  from bigdl.llm.utils.common import invalidInputError
label_desc: Use image node_id 2 for calling the ReLoRACallback obj's underlying member method code with example usage: obj.on_train_begin(_args, _state, control, model) and returns: control