code: def __init__(
      self,
      *average_adapters: List[Union[AdapterCompositionBlock, str]],
      weights: Optional[List[float]] = None,
      normalize_weights: bool = True,
  ):
      super().__init__(*average_adapters)
      if weights is not None:
          # normalize weights
          if normalize_weights:
              sum_weights = sum(weights) if weights else 1
              self.weights = [w / sum_weights for w in weights]
          else:
              self.weights = weights
      else:
          self.weights = [1 / len(average_adapters)] * len(
              average_adapters
          )
  
imports: import itertools
  from collections.abc import Sequence
  from typing import List, Optional, Set, Tuple, Union
  import torch
label_desc: Use image node_id 1 to create a new Average object from inherited base classes: AdapterCompositionBlock with example: obj = Average()