docstr: Takes the mean of the top `k` scores.
  
  Parameters
  ----------
  k
      number of scores to take the mean of. If `k` is left ``None`` then will be set to
      half the number of scores passed in the forward call.
docstr_tok: ["Takes","the","mean","of","the","top","`","k","`","scores",".","Parameters","--","--","--","--","--","k","number","of","scores","to","take","the","mean","of",".","If","`","k","`","is","left","``","None","``","then","will","be","set","to","half","the","number","of","scores","passed","in","the","forward","call","."]
code: def __init__(self, k: Optional[int] = None):
      """Takes the mean of the top `k` scores.
  
      Parameters
      ----------
      k
          number of scores to take the mean of. If `k` is left ``None`` then will be set to
          half the number of scores passed in the forward call.
      """
      super().__init__()
      self.k = k
  
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 TopKAggregator object from inherited base classes: BaseTransformTorch with example: obj = TopKAggregator(k)