docstr: Averages the scores of the detectors in an ensemble.
  
  Parameters
  ----------
  weights
      Optional parameter to weight the scores. If `weights` is left ``None`` then will be set to
      a vector of ones.
  
  Raises
  ------
  ValueError
      If `weights` does not sum to ``1``.
docstr_tok: ["Averages","the","scores","of","the","detectors","in","an","ensemble",".","Parameters","--","--","--","--","--","weights","Optional","parameter","to","weight","the","scores",".","If","`","weights","`","is","left","``","None","``","then","will","be","set","to","a","vector","of","ones",".","Raises","--","--","--","ValueError","If","`","weights","`","does","not","sum","to","``","1","``","."]
code: def __init__(self, weights: Optional[torch.Tensor] = None):
      """Averages the scores of the detectors in an ensemble.
  
      Parameters
      ----------
      weights
          Optional parameter to weight the scores. If `weights` is left ``None`` then will be set to
          a vector of ones.
  
      Raises
      ------
      ValueError
          If `weights` does not sum to ``1``.
      """
      super().__init__()
      if weights is not None and not np.isclose(weights.sum(), 1):
          raise ValueError("Weights must sum to 1.")
      self.weights = weights
  
imports: from abc import ABC, abstractmethod
  from typing import Optional
  from typing_extensions import Self
  import torch
  import numpy
  from torch.nn import Module
  from alibi_detect.exceptions import NotFittedError
label_desc: Use image node_id 1 to create a new AverageAggregator object from inherited base classes: BaseTransformTorch with example: obj = AverageAggregator(weights)