def __init__(self, patterns_per_experience: int, sample_size: int):
        """
        :param patterns_per_experience: number of patterns per experience in the
            memory.
        :param sample_size: number of patterns in memory sample when computing
            reference gradient.
        """

        super().__init__()

        self.patterns_per_experience = int(patterns_per_experience)
        self.sample_size = int(sample_size)

        # One AvalancheDataset for each experience
        self.buffers: List[AvalancheDataset] = []
        self.buffer_dataloader: Optional[GroupBalancedInfiniteDataLoader] = None
        # Placeholder iterator to avoid typing issues
        self.buffer_dliter: Iterator[Any] = iter([])
        # Placeholder Tensor to avoid typing issues
        self.reference_gradients: Tensor = torch.empty(0)

        :param patterns_per_experience: number of patterns per experience in the
            memory.
        :param sample_size: number of patterns in memory sample when computing
            reference gradient.
        
avalanche/training/plugins/agem.py