class_docstr: Prompt Tuning implementation.
  
  Args:
      model_config: The model configuration.
      adapters_config: The adapter configuration.
      base_model_embeddings:
          The embedding layer of the base model (used to initialize the prompt embedding if
          prompt_init='from_string').
code: def average_adapter(
      self, adapter_name: str, input_adapters: Dict[str, float]
  ) -> bool:
      # add new adapter
      if self.add_adapter(adapter_name, -1):
          # average weights
          avg_state_dict = {}
          for name, weight in input_adapters.items():
              if name in self.prompt_tunings:
                  module = self.prompt_tunings[name]
                  for k, v in module.state_dict().items():
                      if k in avg_state_dict:
                          avg_state_dict[k] += weight * v
                      else:
                          avg_state_dict[k] = weight * v
              else:
                  self.delete_adapter(
                      adapter_name
                  )  # clean up before raising error
                  raise ValueError("Adapter {} not found.".format(name))
          # load averaged weights
          self.prompt_tunings[adapter_name].load_state_dict(
              avg_state_dict
          )
          return True
  
      return False
  
imports: import math
  from typing import Callable, Dict, List, Union
  import numpy
  import torch
  from torch import nn
  from transformers import AutoTokenizer
  from transformers.configuration_utils import PretrainedConfig
  from ..composition import AdapterCompositionBlock
  from ..configuration import ModelAdaptersConfig, PromptTuningConfig
  from ..context import ForwardContext
  from .adapter_layer_base import AdapterLayerBase
label_desc: Use image node_id 3 for calling the PromptTuningLayer obj's underlying member method code with example usage: obj.average_adapter(adapter_name, input_adapters) and returns: False, True