class_docstr: This module implements resizing for images and object detection bounding boxes.
class_docstr_tok: ["This","module","implements","resizing","for","images","and","object","detection","bounding","boxes","."]
docstr: Resize `x` and adjust bounding boxes for labels `y` accordingly.
  
  :param x: Input samples. A list of samples is also supported.
  :param y: Label of the samples `x`.
  :return: Transformed samples and labels.
docstr_tok: ["Resize","`","x","`","and","adjust","bounding","boxes","for","labels","`","y","`","accordingly",".",":","param","x",":","Input","samples",".","A","list","of","samples","is","also","supported",".",":","param","y",":","Label","of","the","samples","`","x","`",".",":","return",":","Transformed","samples","and","labels","."]
code: def __call__(
      self,
      x: np.ndarray,
      y: Optional[
          Union[np.ndarray, List[Dict[str, np.ndarray]]]
      ] = None,
  ) -> Tuple[
      np.ndarray,
      Optional[Union[np.ndarray, List[Dict[str, np.ndarray]]]],
  ]:
      """
      Resize `x` and adjust bounding boxes for labels `y` accordingly.
  
      :param x: Input samples. A list of samples is also supported.
      :param y: Label of the samples `x`.
      :return: Transformed samples and labels.
      """
      x_preprocess_list = []
      y_preprocess: Optional[
          Union[np.ndarray, List[Dict[str, np.ndarray]]]
      ]
      if y is not None and self.label_type == "object_detection":
          y_preprocess = []
      else:
          y_preprocess = y
  
      for i, x_i in enumerate(
          tqdm(x, desc="ImageResize", disable=not self.verbose)
      ):
          if self.channels_first:
              x_i = np.transpose(x_i, (1, 2, 0))
  
          # Resize image: OpenCV swaps height and width
          x_resized = cv2.resize(
              x_i,
              (self.width, self.height),
              interpolation=self.interpolation,
          )
  
          if self.channels_first:
              x_resized = np.transpose(x_resized, (2, 0, 1))
  
          x_preprocess_list.append(x_resized)
  
          if self.label_type == "object_detection" and y is not None:
              y_resized: Dict[str, np.ndarray] = {}
  
              # Copy labels and ensure types
              if isinstance(y, list) and isinstance(y_preprocess, list):
                  y_i = y[i]
                  if isinstance(y_i, dict):
                      y_resized = {
                          k: np.copy(v) for k, v in y_i.items()
                      }
                  else:
                      raise TypeError(
                          "Wrong type for `y` and label_type=object_detection."
                      )
              else:
                  raise TypeError(
                      "Wrong type for `y` and label_type=object_detection."
                  )
  
              # Calculate scaling factor
              height, width, _ = x_i.shape
              height_scale = self.height / height
              width_scale = self.width / width
  
              # Resize bounding boxes
              y_resized["boxes"][:, 0] *= width_scale
              y_resized["boxes"][:, 1] *= height_scale
              y_resized["boxes"][:, 2] *= width_scale
              y_resized["boxes"][:, 3] *= height_scale
  
              y_preprocess.append(y_resized)
  
      x_preprocess = np.stack(x_preprocess_list)
      if self.clip_values is not None:
          x_preprocess = np.clip(
              x_preprocess, self.clip_values[0], self.clip_values[1]
          )
  
      return x_preprocess, y_preprocess
  
file_path: adversarial-robustness-toolbox/art/preprocessing/image/image_resize/numpy.py
imports: import logging
  from typing import Dict, List, Optional, TYPE_CHECKING, Tuple, Union
  import numpy
  import cv2
  from tqdm.auto import tqdm
  from art.preprocessing.preprocessing import Preprocessor
label_desc: Use image node_id 2 for calling the ImageResize obj's underlying member method code with example usage: obj.__call__(x, y) and returns: x_preprocess,  y_preprocess