class_docstr: This module implements EoT of zoom blur with uniformly sampled zoom factor.
docstr: Transformation of an image with randomly sampled zoom blur.
  
  :param x: Input samples.
  :param y: Label of the samples `x`.
  :return: Transformed samples and labels.
code: def _transform(
      self,
      x: "torch.Tensor",
      y: Optional[
          Union["torch.Tensor", List[Dict[str, "torch.Tensor"]]]
      ],
      **kwargs,
  ) -> Tuple[
      "torch.Tensor",
      Optional[Union["torch.Tensor", List[Dict[str, "torch.Tensor"]]]],
  ]:
      """
      Transformation of an image with randomly sampled zoom blur.
  
      :param x: Input samples.
      :param y: Label of the samples `x`.
      :return: Transformed samples and labels.
      """
      import torch
      import torchvision
  
      nb_zooms = 10
      x_blur = torch.zeros_like(x)
      max_zoom_i = np.random.uniform(
          low=self.zoom_range[0], high=self.zoom_range[1]
      )
      zooms = np.arange(
          start=1.0, stop=max_zoom_i, step=(max_zoom_i - 1.0) / nb_zooms
      )
  
      height = x.shape[1]
      width = x.shape[2]
  
      x_nchw = x.permute(0, 3, 1, 2)
  
      for zoom in zooms:
          size = [int(a * zoom) for a in x.shape[1:3]]
          x_resized = torchvision.transforms.functional.resize(
              img=x_nchw,
              size=size,
              interpolation=torchvision.transforms.InterpolationMode.BILINEAR,
          ).permute(0, 2, 3, 1)
  
          trim_top = (x_resized.shape[1] - height) // 2
          trim_left = (x_resized.shape[2] - width) // 2
  
          x_blur += x_resized[
              0:1,
              trim_top : trim_top + height,
              trim_left : trim_left + width,
              :,
          ]
  
      x_out = (x + x_blur) / (nb_zooms + 1)
      return (
          torch.clamp(
              x_out, min=self.clip_values[0], max=self.clip_values[1]
          ),
          y,
      )
  
file_path: adversarial-robustness-toolbox/art/preprocessing/expectation_over_transformation/natural_corruptions/zoom_blur/pytorch.py
imports: import logging
  from typing import Dict, List, Tuple, Union, TYPE_CHECKING, Optional
  import numpy
  from art.preprocessing.expectation_over_transformation.pytorch import EoTPyTorch
label_desc: Use image node_id 2 for calling the EoTZoomBlurPyTorch obj's underlying member method code with example usage: obj._transform(x, y) and returns: torch,  y