def compute_losses(self, x: np.ndarray, y: np.ndarray) -> dict[str, np.ndarray]:  # type: ignore
        """
        Compute all loss components.

        :param x: Samples of shape (nb_samples, nb_features) or (nb_samples, nb_pixels_1, nb_pixels_2,
                  nb_channels) or (nb_samples, nb_channels, nb_pixels_1, nb_pixels_2).
        :param y: Target values (class labels) one-hot-encoded of shape `(nb_samples, nb_classes)` or indices
                  of shape `(nb_samples,)`.
        :return: Dictionary of loss components.
        """
        # Apply preprocessing
        x_preprocessed, _ = self._apply_preprocessing(x, y=None, fit=False)

        # Create feed_dict
        feed_dict = {self.images: x_preprocessed}

        for placeholder, value in zip(self._groundtruth_boxes_list, y):
            feed_dict[placeholder] = value["boxes"]

        for placeholder, value in zip(self._groundtruth_classes_list, y):
            feed_dict[placeholder] = value["labels"]

        for placeholder, value in zip(self._groundtruth_weights_list, y):
            feed_dict[placeholder] = value["scores"]

        # Get the losses graph
        if not hasattr(self, "_losses_dict"):
            self._losses_dict = {}
            for loss_name in self.attack_losses:
                self._losses_dict[loss_name] = self._losses[loss_name]

        losses: dict[str, np.ndarray] = {}
        for loss_name in self.attack_losses:
            loss_value = self._sess.run(self._losses_dict[loss_name], feed_dict=feed_dict)
            losses[loss_name] = loss_value

        return losses

        Compute all loss components.

        :param x: Samples of shape (nb_samples, nb_features) or (nb_samples, nb_pixels_1, nb_pixels_2,
                  nb_channels) or (nb_samples, nb_channels, nb_pixels_1, nb_pixels_2).
        :param y: Target values (class labels) one-hot-encoded of shape `(nb_samples, nb_classes)` or indices
                  of shape `(nb_samples,)`.
        :return: Dictionary of loss components.
        
art/estimators/object_detection/tensorflow_faster_rcnn.py