code: def get_pytorch_yolo(get_default_cifar10_subset):
      """
      This class tests the PyTorchYolo object detector.
      """
      import cv2
      import torch
  
      from pytorchyolo import models
      from pytorchyolo.utils.loss import compute_loss
  
      from art.estimators.object_detection.pytorch_yolo import (
          PyTorchYolo,
      )
  
      model_path = "/tmp/PyTorch-YOLOv3/config/yolov3.cfg"
      weights_path = "/tmp/PyTorch-YOLOv3/weights/yolov3.weights"
      model = models.load_model(
          model_path=model_path, weights_path=weights_path
      )
  
      class YoloV3(torch.nn.Module):
          def __init__(self, model):
              super().__init__()
              self.model = model
  
          def forward(self, x, targets=None):
              if self.training:
                  outputs = self.model(x)
                  # loss is averaged over a batch. Thus, for patch generation use batch_size = 1
                  loss, _ = compute_loss(outputs, targets, self.model)
  
                  loss_components = {"loss_total": loss}
  
                  return loss_components
              else:
                  return self.model(x)
  
      model = YoloV3(model)
  
      params = [p for p in model.parameters() if p.requires_grad]
      optimizer = torch.optim.SGD(params, lr=0.01)
  
      object_detector = PyTorchYolo(
          model=model,
          input_shape=(3, 416, 416),
          optimizer=optimizer,
          clip_values=(0, 1),
          channels_first=True,
          attack_losses=("loss_total",),
      )
  
      (_, _), (x_test_cifar10, _) = get_default_cifar10_subset
  
      x_test = cv2.resize(
          x_test_cifar10[0].transpose((1, 2, 0)),
          dsize=(416, 416),
          interpolation=cv2.INTER_CUBIC,
      ).transpose((2, 0, 1))
      x_test = np.expand_dims(x_test, axis=0)
      x_test = np.repeat(x_test, repeats=2, axis=0)
  
      # Create labels
  
      result = object_detector.predict(x=x_test)
  
      y_test = [
          {
              "boxes": result[0]["boxes"],
              "labels": result[0]["labels"],
              "scores": np.ones_like(result[0]["labels"]),
          },
          {
              "boxes": result[1]["boxes"],
              "labels": result[1]["labels"],
              "scores": np.ones_like(result[1]["labels"]),
          },
      ]
  
      yield object_detector, x_test, y_test
  
file_path: adversarial-robustness-toolbox/tests/estimators/object_detection/conftest.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import numpy
  import pytest
label_desc: Use image node_id 4 for calling a global function with example usage: get_pytorch_yolo(get_default_cifar10_subset) and returns: loss_components, self