class_docstr: This module implements the model- and task specific estimator for YOLO v3, v5 object detector models in PyTorch.
  
  | Paper link: https://arxiv.org/abs/1804.02767
class_docstr_tok: ["This","module","implements","the","model-","and","task","specific","estimator","for","YOLO","v3",",","v5","object","detector","models","in","PyTorch",".","|","Paper","link",":","https",":","\/\/arxiv.org\/abs\/1804.02767"]
docstr: Initialization.
  
  :param model: YOLO v3 or v5 model wrapped as demonstrated in examples/get_started_yolo.py.
                The output of the model is `List[Dict[str, 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.
                - scores [N]: the scores of each prediction.
  :param input_shape: The shape of one input sample.
  :param optimizer: The optimizer for training the classifier.
  :param clip_values: Tuple of the form `(min, max)` of floats or `np.ndarray` representing the minimum and
         maximum values allowed for features. If floats are provided, these will be used as the range of all
         features. If arrays are provided, each value will be considered the bound for a feature, thus
         the shape of clip values needs to match the total number of features.
  :param channels_first: Set channels first or last.
  :param preprocessing_defences: Preprocessing defence(s) to be applied by the classifier.
  :param postprocessing_defences: Postprocessing defence(s) to be applied by the classifier.
  :param preprocessing: Tuple of the form `(subtrahend, divisor)` of floats or `np.ndarray` of values to be
         used for data preprocessing. The first value will be subtracted from the input. The input will then
         be divided by the second one.
  :param attack_losses: Tuple of any combination of strings of loss components: 'loss_classifier', 'loss_box_reg',
                        'loss_objectness', and 'loss_rpn_box_reg'.
  :param device_type: Type of device to be used for model and tensors, if `cpu` run on CPU, if `gpu` run on GPU
                      if available otherwise run on CPU.
docstr_tok: ["Initialization",".",":","param","model",":","YOLO","v3","or","v5","model","wrapped","as","demonstrated","in","examples\/get_started_yolo.py",".","The","output","of","the","model","is","`","List","[","Dict","[","str",",","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",".","-","scores","[","N","]",":","the","scores","of","each","prediction",".",":","param","input_shape",":","The","shape","of","one","input","sample",".",":","param","optimizer",":","The","optimizer","for","training","the","classifier",".",":","param","clip_values",":","Tuple","of","the","form","`","(","min",",","max",")","`","of","floats","or","`","np.ndarray","`","representing","the","minimum","and","maximum","values","allowed","for","features",".","If","floats","are","provided",",","these","will","be","used","as","the","range","of","all","features",".","If","arrays","are","provided",",","each","value","will","be","considered","the","bound","for","a","feature",",","thus","the","shape","of","clip","values","needs","to","match","the","total","number","of","features",".",":","param","channels_first",":","Set","channels","first","or","last",".",":","param","preprocessing_defences",":","Preprocessing","defence","(","s",")","to","be","applied","by","the","classifier",".",":","param","postprocessing_defences",":","Postprocessing","defence","(","s",")","to","be","applied","by","the","classifier",".",":","param","preprocessing",":","Tuple","of","the","form","`","(","subtrahend",",","divisor",")","`","of","floats","or","`","np.ndarray","`","of","values","to","be","used","for","data","preprocessing",".","The","first","value","will","be","subtracted","from","the","input",".","The","input","will","then","be","divided","by","the","second","one",".",":","param","attack_losses",":","Tuple","of","any","combination","of","strings","of","loss","components",":","'loss_classifier","'",",","'loss_box_reg","'",",","'loss_objectness","'",",","and","'loss_rpn_box_reg","'",".",":","param","device_type",":","Type","of","device","to","be","used","for","model","and","tensors",",","if","`","cpu","`","run","on","CPU",",","if","`","gpu","`","run","on","GPU","if","available","otherwise","run","on","CPU","."]
code: def __init__(
      self,
      model: "torch.nn.Module",
      input_shape: Tuple[int, ...] = (3, 416, 416),
      optimizer: Optional["torch.optim.Optimizer"] = None,
      clip_values: Optional["CLIP_VALUES_TYPE"] = None,
      channels_first: Optional[bool] = True,
      preprocessing_defences: Union[
          "Preprocessor", List["Preprocessor"], None
      ] = None,
      postprocessing_defences: Union[
          "Postprocessor", List["Postprocessor"], None
      ] = None,
      preprocessing: "PREPROCESSING_TYPE" = None,
      attack_losses: Tuple[str, ...] = (
          "loss_classifier",
          "loss_box_reg",
          "loss_objectness",
          "loss_rpn_box_reg",
      ),
      device_type: str = "gpu",
  ):
      """
      Initialization.
  
      :param model: YOLO v3 or v5 model wrapped as demonstrated in examples/get_started_yolo.py.
                    The output of the model is `List[Dict[str, 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.
                    - scores [N]: the scores of each prediction.
      :param input_shape: The shape of one input sample.
      :param optimizer: The optimizer for training the classifier.
      :param clip_values: Tuple of the form `(min, max)` of floats or `np.ndarray` representing the minimum and
             maximum values allowed for features. If floats are provided, these will be used as the range of all
             features. If arrays are provided, each value will be considered the bound for a feature, thus
             the shape of clip values needs to match the total number of features.
      :param channels_first: Set channels first or last.
      :param preprocessing_defences: Preprocessing defence(s) to be applied by the classifier.
      :param postprocessing_defences: Postprocessing defence(s) to be applied by the classifier.
      :param preprocessing: Tuple of the form `(subtrahend, divisor)` of floats or `np.ndarray` of values to be
             used for data preprocessing. The first value will be subtracted from the input. The input will then
             be divided by the second one.
      :param attack_losses: Tuple of any combination of strings of loss components: 'loss_classifier', 'loss_box_reg',
                            'loss_objectness', and 'loss_rpn_box_reg'.
      :param device_type: Type of device to be used for model and tensors, if `cpu` run on CPU, if `gpu` run on GPU
                          if available otherwise run on CPU.
      """
      import torch
  
      super().__init__(
          model=model,
          clip_values=clip_values,
          channels_first=channels_first,
          preprocessing_defences=preprocessing_defences,
          postprocessing_defences=postprocessing_defences,
          preprocessing=preprocessing,
          device_type=device_type,
      )
  
      self._input_shape = input_shape
      self._optimizer = optimizer
      self._attack_losses = attack_losses
  
      if self.clip_values is not None:
          if self.clip_values[0] != 0:
              raise ValueError(
                  "This estimator requires un-normalized input images with clip_vales=(0, max_value)."
              )
          if self.clip_values[1] <= 0:  # pragma: no cover
              raise ValueError(
                  "This estimator requires un-normalized input images with clip_vales=(0, max_value)."
              )
  
      if self.postprocessing_defences is not None:
          raise ValueError(
              "This estimator does not support `postprocessing_defences`."
          )
  
      self._model: torch.nn.Module
      self._model.to(self._device)
      self._model.eval()
  
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 1 to create a new PyTorchYolo object from inherited base classes: ObjectDetectorMixin, PyTorchEstimator with example: obj = PyTorchYolo(model, input_shape, optimizer, clip_values, channels_first, preprocessing_defences, postprocessing_defences, preprocessing, attack_losses, device_type)