def _get_average_reconstruction_error(
        self, strategy: "SupervisedTemplate", task_label
    ):
        """Given a task label, retrieves an autoencoder and
        evaluates the reconstruction error on the current batch of data.
        """
        autoencoder = self._get_autoencoder(strategy, task_label)

        ae_strategy = AETraining(
            model=autoencoder,
            optimizer=SGD(autoencoder.parameters(), lr=strategy.ae_lr),
            device=strategy.device,
            eval_mb_size=100,
            eval_every=-1,
        )

        # Run evaluation on autoencoder
        ae_strategy.eval(strategy.experience)

        # Build the key for evaluation metrics dictionary
        if strategy.experience.origin_stream.name == "train":
            key = "Loss_Stream/eval_phase/train_stream/Task" + "{:0>3d}".format(
                strategy.experience.task_label
            )

        elif strategy.experience.origin_stream.name == "test":
            key = "Loss_Stream/eval_phase/test_stream/Task" + "{:0>3d}".format(
                strategy.experience.task_label
            )

        # Query for reconstruction loss
        error = ae_strategy.evaluator.get_last_metrics()[key]

        return error
Given a task label, retrieves an autoencoder and
        evaluates the reconstruction error on the current batch of data.
        
avalanche/training/supervised/expert_gate.py