code: def initialize_adapter(
      model: PreTrainedModel, config_obj: "LLMModelConfig"  # noqa F821
  ) -> Union["PeftModel", PreTrainedModel]:  # noqa F821
      """Wrap a pretrained model with a PEFT model for fine-tuning.
  
      Args:
           model: Pretrained model to fine-tune with an adapter.
           config_obj: LLM config
  
      Returns:
          `model` wrapped in a PEFT model if an adapter config was provided, otherwise `model`.
      """
      # Only load a PEFT model if the config specifies an adapter, otherwise return the model unaltered.
      if config_obj.adapter:
          if config_obj.adapter.pretrained_adapter_weights:
              # Load pretrained adapter weights if specified.
              logger.info(
                  f"Using pretrained adapter weights: {config_obj.adapter.pretrained_adapter_weights}"
              )
  
              # Leave this import inline to support a minimal install of Ludwig
              from peft import (
                  MODEL_TYPE_TO_PEFT_MODEL_MAPPING,
                  PeftConfig,
              )  # noqa
  
              peft_config = PeftConfig.from_pretrained(
                  config_obj.adapter.pretrained_adapter_weights
              )
  
              model = MODEL_TYPE_TO_PEFT_MODEL_MAPPING[
                  peft_config.task_type
              ].from_pretrained(
                  model, config_obj.adapter.pretrained_adapter_weights
              )
          else:
              # Leave this import inline to support a minimal install of Ludwig
              from peft import get_peft_model, TaskType  # noqa
  
              # If no pretrained adapter is provided, we want to load untrained weights into the model
              peft_config = config_obj.adapter.to_config(
                  task_type=TaskType.CAUSAL_LM,
                  tokenizer_name_or_path=config_obj.base_model,
              )
  
              model = get_peft_model(model, peft_config)
  
      return model
  
imports: import copy
  import logging
  import tempfile
  from typing import Dict, Optional, Tuple, TYPE_CHECKING, Union
  import torch
  import torch.nn.functional
  import transformers
  from bitsandbytes.nn.modules import Embedding
  from packaging import version
  from transformers import AutoConfig, AutoModelForCausalLM, PreTrainedModel, PreTrainedTokenizer, TextStreamer
  from ludwig.constants import IGNORE_INDEX_TOKEN_ID, LOGITS, PREDICTIONS, PROBABILITIES
  from ludwig.schema.trainer import LLMTrainerConfig
  from ludwig.utils.error_handling_utils import default_retry
  from ludwig.utils.logging_utils import log_once
  from ludwig.utils.model_utils import find_embedding_layer_with_path
label_desc: Use image node_id 3 for calling a global function with example usage: initialize_adapter(model, config_obj) and returns: model