code: def load_llama_adapter(model, cfg):
      # type: (PreTrainedModel, DictDefault) -> Tuple[PreTrainedModel, Optional[PeftConfig]]
      from peft import AdaptionPromptConfig, PeftModel, get_peft_model
  
      peft_config = AdaptionPromptConfig(
          adapter_layers=cfg.peft_adapter.layers,  # layers (L)
          adapter_len=cfg.peft_adapter.len,  # prompt length (K)
          task_type="CAUSAL_LM",
      )
  
      if cfg.lora_model_dir:
          LOG.debug("Loading pretained PEFT - llama_adapter")
          model = PeftModel.from_pretrained(
              model,
              cfg.lora_model_dir,
              torch_dtype=torch.float16,
          )
      else:
          model = get_peft_model(model, peft_config)
  
      model.print_trainable_parameters()
  
      return model, peft_config
  
imports: import logging
  import math
  import os
  from typing import Any, Optional, Tuple, Union
  import addict
  import bitsandbytes
  import torch
  import transformers
  from optimum.bettertransformer import BetterTransformer
  from peft import PeftConfig, prepare_model_for_kbit_training
  from peft.tuners.lora import QuantLinear
  from transformers import AddedToken, AutoConfig, AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, GPTQConfig, PreTrainedModel, PreTrainedTokenizerBase
  from transformers.deepspeed import is_deepspeed_zero3_enabled
  from axolotl.models.mamba import fix_mamba_attn_for_loss
  from axolotl.prompt_tokenizers import LLAMA_DEFAULT_EOS_TOKEN
  from axolotl.utils.bench import log_gpu_memory_usage
  from axolotl.utils.chat_templates import chat_templates
  from axolotl.utils.dict import DictDefault
  from axolotl.utils.lora_embeddings import get_linear_embedding_layers
label_desc: Use image node_id 6 for calling a global function with example usage: load_llama_adapter(model, cfg) and returns: model,  peft_config