class_docstr: This class implements a model-specific object detector using DEtection TRansformer (DETR)
  and PyTorch following the input and output formats of torchvision.
class_docstr_tok: ["This","class","implements","a","model-specific","object","detector","using","DEtection","TRansformer","(","DETR",")","and","PyTorch","following","the","input","and","output","formats","of","torchvision","."]
docstr: Resize the input and targets to dimensions expected by DETR.
  
  :param x: Array or Tensor representing images of any size
  :param y: List of targets to be transformed
  :param height: Int representing desired height, the default is compatible with DETR
  :param width: Int representing desired width, the default is compatible with DETR
docstr_tok: ["Resize","the","input","and","targets","to","dimensions","expected","by","DETR",".",":","param","x",":","Array","or","Tensor","representing","images","of","any","size",":","param","y",":","List","of","targets","to","be","transformed",":","param","height",":","Int","representing","desired","height",",","the","default","is","compatible","with","DETR",":","param","width",":","Int","representing","desired","width",",","the","default","is","compatible","with","DETR"]
code: def _apply_resizing(
      self,
      x: Union[np.ndarray, "torch.Tensor"],
      y: Any = None,
      height: int = 800,
      width: int = 800,
  ) -> Tuple[Union[np.ndarray, "torch.Tensor"], List[Any]]:
      """
      Resize the input and targets to dimensions expected by DETR.
  
      :param x: Array or Tensor representing images of any size
      :param y: List of targets to be transformed
      :param height: Int representing desired height, the default is compatible with DETR
      :param width: Int representing desired width, the default is compatible with DETR
      """
      import cv2
      import torchvision.transforms as T
      import torch
      from art.estimators.object_detection.detr import (
          revert_rescale_bboxes,
      )
  
      if (
          self._input_shape[1] < self.MIN_IMAGE_SIZE
          or self._input_shape[1] > self.MAX_IMAGE_SIZE
          or self._input_shape[2] < self.MIN_IMAGE_SIZE
          or self.input_shape[2] > self.MAX_IMAGE_SIZE
      ):
          resized_imgs = []
          if isinstance(x, torch.Tensor):
              x = T.Resize(size=(height, width))(x).to(self.device)
          else:
              for i in x:
                  resized = cv2.resize(
                      i.transpose(1, 2, 0),
                      dsize=(height, width),
                      interpolation=cv2.INTER_CUBIC,
                  )
                  resized = resized.transpose(2, 0, 1)
                  resized_imgs.append(resized)
              x = np.array(resized_imgs)
  
      elif self._input_shape[1] != self._input_shape[2]:
          rescale_dim = max(self._input_shape[1], self._input_shape[2])
          resized_imgs = []
          if isinstance(x, torch.Tensor):
              x = T.Resize(size=(rescale_dim, rescale_dim))(x).to(
                  self.device
              )
          else:
              for i in x:
                  resized = cv2.resize(
                      i.transpose(1, 2, 0),
                      dsize=(rescale_dim, rescale_dim),
                      interpolation=cv2.INTER_CUBIC,
                  )
                  resized = resized.transpose(2, 0, 1)
                  resized_imgs.append(resized)
              x = np.array(resized_imgs)
  
      targets: List[Any] = []
      if y is not None:
          if isinstance(y[0]["boxes"], torch.Tensor):
              for target in y:
                  assert isinstance(target["boxes"], torch.Tensor)
                  assert isinstance(target["labels"], torch.Tensor)
                  assert isinstance(target["scores"], torch.Tensor)
                  cxcy_norm = revert_rescale_bboxes(
                      target["boxes"],
                      (self.input_shape[2], self.input_shape[1]),
                  )
                  targets.append(
                      {
                          "labels": target["labels"]
                          .type(torch.int64)
                          .to(self.device),
                          "boxes": cxcy_norm.to(self.device),
                          "scores": target["scores"]
                          .type(torch.float)
                          .to(self.device),
                      }
                  )
          else:
              for target in y:
                  tensor_box = torch.from_numpy(target["boxes"])
                  cxcy_norm = revert_rescale_bboxes(
                      tensor_box,
                      (self.input_shape[2], self.input_shape[1]),
                  )
                  targets.append(
                      {
                          "labels": torch.from_numpy(target["labels"])
                          .type(torch.int64)
                          .to(self.device),
                          "boxes": cxcy_norm.to(self.device),
                          "scores": torch.from_numpy(target["scores"])
                          .type(torch.float)
                          .to(self.device),
                      }
                  )
      return x, targets
  
file_path: adversarial-robustness-toolbox/art/estimators/object_detection/pytorch_detection_transformer.py
imports: import logging
  from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union, Any
  import numpy
  from art.estimators.object_detection.object_detector import ObjectDetectorMixin
  from art.estimators.pytorch import PyTorchEstimator
label_desc: Use image node_id 12 for calling the PyTorchDetectionTransformer obj's underlying member method code with example usage: obj._apply_resizing(x, y, height, width) and returns: x,  targets