code: def average_adapter(
      self, adapter_name: str, input_adapters: Dict[str, float]
  ) -> bool:
      # add new adapter
      if self.add_adapter(adapter_name, self.layer_idx):
          # average weights
          avg_state_dict = {}
          for name, weight in input_adapters.items():
              if name in self.adapters:
                  module = self.adapters[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.adapters[adapter_name].load_state_dict(avg_state_dict)
          return True
  
      return False
  
imports: from typing import Dict, List, Mapping, NamedTuple, Optional, Union
  import torch
  from torch import nn
  from ..composition import AdapterCompositionBlock, Average, BatchSplit, Fuse, Parallel, Split, Stack, adjust_tensors_for_parallel
  from ..configuration import BnConfig
  from ..context import ForwardContext
  from .adapter_layer_base import ComposableAdapterLayerBase
  from .modeling import Adapter, BertFusion, ParallelAdapter
label_desc: Use image node_id 4 for calling the BottleneckLayer obj's underlying member method code with example usage: obj.average_adapter(adapter_name, input_adapters) and returns: False, True