def _transform_boxes_pad_to_aspect_ratio(
        self, boxes, input_height, input_width
    ):
        """Transforms bounding boxes for padding to aspect ratio."""
        ops = self.backend
        height_ratio = ops.cast(self.height / input_height, dtype=boxes.dtype)
        width_ratio = ops.cast(self.width / input_width, dtype=boxes.dtype)
        min_aspect_ratio = ops.numpy.minimum(height_ratio, width_ratio)
        y_offset = (self.height - input_height * min_aspect_ratio) // 2
        x_offset = (self.width - input_width * min_aspect_ratio) // 2
        return ops.numpy.stack(
            [
                boxes[..., 0] * min_aspect_ratio + x_offset,
                boxes[..., 1] * min_aspect_ratio + y_offset,
                boxes[..., 2] * min_aspect_ratio + x_offset,
                boxes[..., 3] * min_aspect_ratio + y_offset,
            ],
            axis=-1,
        )
Transforms bounding boxes for padding to aspect ratio.
keras/src/layers/preprocessing/image_preprocessing/resizing.py