def _transform(self, x: "tf.Tensor", y: "tf.Tensor" | None, **kwargs) -> tuple["tf.Tensor", "tf.Tensor" | None]:
        """
        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 tensorflow as tf

        nb_zooms = 10
        x_blur = tf.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]

        for zoom in zooms:
            size = [int(a * zoom) for a in x.shape[1:3]]
            x_resized = tf.image.resize(
                images=x,
                size=size,
                method=tf.image.ResizeMethod.BILINEAR,
                preserve_aspect_ratio=True,
                antialias=False,
                name=None,
            )

            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 tf.clip_by_value(x_out, clip_value_min=self.clip_values[0], clip_value_max=self.clip_values[1]), y

        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.
        
art/preprocessing/expectation_over_transformation/natural_corruptions/zoom_blur/tensorflow.py