def criterion(self):
        """
        Compute the loss function.

        The initial loss dictionary must be obtained by first running the
        forward pass (the model will return the detection_loss_dict).
        This function will only obtain a single value.

        Beware that the loss can only be obtained for the training phase as no
        loss dictionary is returned when evaluating.
        """

        assert self.detection_loss_dict is not None
        if self.is_training:
            return sum(loss for loss in self.detection_loss_dict.values())
        else:
            # eval does not compute the loss directly.
            # Metrics will use self.mb_output and self.detection_predictions
            # to compute AP, AR, ...
            self.detection_predictions = {
                target["image_id"].item(): output
                for target, output in zip(self.mb_y, self.mb_output)
            }
            return torch.zeros((1,))

        Compute the loss function.

        The initial loss dictionary must be obtained by first running the
        forward pass (the model will return the detection_loss_dict).
        This function will only obtain a single value.

        Beware that the loss can only be obtained for the training phase as no
        loss dictionary is returned when evaluating.
        
avalanche/training/supervised/naive_object_detection.py