class_docstr: This module implements the task specific estimator for PyTorch object detection models following the input and
  output formats of torchvision.
class_docstr_tok: ["This","module","implements","the","task","specific","estimator","for","PyTorch","object","detection","models","following","the","input","and","output","formats","of","torchvision","."]
docstr: Compute all loss components.
  
  :param x: Samples of shape NCHW or NHWC.
  :param y: Target values of format `List[Dict[str, Union[np.ndarray, torch.Tensor]]]`, one for each input image.
            The fields of the Dict are as follows:
  
            - boxes [N, 4]: the boxes in [x1, y1, x2, y2] format, with 0 <= x1 < x2 <= W and 0 <= y1 < y2 <= H.
            - labels [N]: the labels for each image.
  :return: Dictionary of loss components.
docstr_tok: ["Compute","all","loss","components",".",":","param","x",":","Samples","of","shape","NCHW","or","NHWC",".",":","param","y",":","Target","values","of","format","`","List","[","Dict","[","str",",","Union","[","np.ndarray",",","torch.Tensor","]","]","]","`",",","one","for","each","input","image",".","The","fields","of","the","Dict","are","as","follows",":","-","boxes","[","N",",","4","]",":","the","boxes","in","[","x1",",","y1",",","x2",",","y2","]","format",",","with","0","<","=","x1","<","x2","<","=","W","and","0","<","=","y1","<","y2","<","=","H.","-","labels","[","N","]",":","the","labels","for","each","image",".",":","return",":","Dictionary","of","loss","components","."]
code: def compute_losses(
      self,
      x: np.ndarray,
      y: List[Dict[str, Union[np.ndarray, "torch.Tensor"]]],
  ) -> Dict[str, np.ndarray]:
      """
      Compute all loss components.
  
      :param x: Samples of shape NCHW or NHWC.
      :param y: Target values of format `List[Dict[str, Union[np.ndarray, torch.Tensor]]]`, one for each input image.
                The fields of the Dict are as follows:
  
                - boxes [N, 4]: the boxes in [x1, y1, x2, y2] format, with 0 <= x1 < x2 <= W and 0 <= y1 < y2 <= H.
                - labels [N]: the labels for each image.
      :return: Dictionary of loss components.
      """
      loss_components, _ = self._get_losses(x=x, y=y)
      output = {}
      for key, value in loss_components.items():
          output[key] = value.detach().cpu().numpy()
      return output
  
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.object_detection.utils import cast_inputs_to_pt
  from art.estimators.pytorch import PyTorchEstimator
label_desc: Use image node_id 14 for calling the PyTorchObjectDetector obj's underlying member method code with example usage: obj.compute_losses(x, y) and returns: output