class_docstr: This class implements a model-specific object detector using Faster-RCNN and TensorFlowV2.
docstr: Compute the loss.
  
  :param x: Sample input with shape as expected by the model.
  :param y: Targets of format `List[Dict[str, np.ndarray]]`, one for each input image. The fields of the Dict are
            as follows:
              - boxes [N, 4]: the boxes in [y1, x1, y2, x2] format, with 0 <= x1 < x2 <= W and 0 <= y1 < y2 <= H.
              - labels [N]: the labels for each image in TensorFlow format.
              - scores [N]: the scores or each prediction.
  :return: np.float32 representing total loss.
docstr_tok: ["Compute","the","loss",".",":","param","x",":","Sample","input","with","shape","as","expected","by","the","model",".",":","param","y",":","Targets","of","format","`","List","[","Dict","[","str",",","np.ndarray","]","]","`",",","one","for","each","input","image",".","The","fields","of","the","Dict","are","as","follows",":","-","boxes","[","N",",","4","]",":","the","boxes","in","[","y1",",","x1",",","y2",",","x2","]","format",",","with","0","<","=","x1","<","x2","<","=","W","and","0","<","=","y1","<","y2","<","=","H.","-","labels","[","N","]",":","the","labels","for","each","image","in","TensorFlow","format",".","-","scores","[","N","]",":","the","scores","or","each","prediction",".",":","return",":","np.float32","representing","total","loss","."]
code: def compute_loss(
      self, x: np.ndarray, y: np.ndarray, **kwargs
  ) -> np.ndarray:
      """
      Compute the loss.
  
      :param x: Sample input with shape as expected by the model.
      :param y: Targets of format `List[Dict[str, np.ndarray]]`, one for each input image. The fields of the Dict are
                as follows:
                  - boxes [N, 4]: the boxes in [y1, x1, y2, x2] format, with 0 <= x1 < x2 <= W and 0 <= y1 < y2 <= H.
                  - labels [N]: the labels for each image in TensorFlow format.
                  - scores [N]: the scores or each prediction.
      :return: np.float32 representing total loss.
      """
  
      import tensorflow as tf
  
      # Apply preprocessing
      x_preprocessed, _ = self._apply_preprocessing(
          x, y=None, fit=False
      )
      x_preprocessed = tf.convert_to_tensor(x_preprocessed)
  
      groundtruth_boxes_list = [
          tf.convert_to_tensor(y[i]["boxes"]) for i in range(x.shape[0])
      ]
  
      groundtruth_classes_list = [
          tf.one_hot(
              groundtruth_class,
              self._model.num_classes,
              on_value=1.0,
              off_value=0.0,
          )
          for groundtruth_class in [
              tf.convert_to_tensor(y[i]["labels"])
              for i in range(x.shape[0])
          ]
      ]
  
      groundtruth_weights_list = [
          [1] * len(y[i]["labels"]) for i in range(x.shape[0])
      ]
  
      self._model.provide_groundtruth(
          groundtruth_boxes_list=groundtruth_boxes_list,
          groundtruth_classes_list=groundtruth_classes_list,
          groundtruth_weights_list=groundtruth_weights_list,
      )
  
      preprocessed_images, true_image_shapes = self._model.preprocess(
          x_preprocessed
      )
      predictions = self._model.predict(
          preprocessed_images, true_image_shapes
      )
      losses = self._model.loss(predictions, true_image_shapes)
  
      loss = None
      for loss_name in self.attack_losses:
          if loss is None:
              loss = losses[loss_name].numpy()
          else:
              loss = loss + losses[loss_name].numpy()
  
      total_loss = np.array([loss])
  
      return total_loss
  
imports: import logging
  from typing import List, Dict, Optional, Tuple, Union, TYPE_CHECKING
  import numpy
  from art.estimators.object_detection.object_detector import ObjectDetectorMixin
  from art.estimators.tensorflow import TensorFlowV2Estimator
  from art.utils import get_file
  from art import config
label_desc: Use image node_id 12 for calling the TensorFlowV2FasterRCNN obj's underlying member method code with example usage: obj.compute_loss(x, y) and returns: total_loss