def forward(
        self,
        x: "tf.Tensor",
        y: "tf.Tensor" | list[dict[str, "tf.Tensor"]] | None = None,
    ) -> tuple["tf.Tensor", "tf.Tensor" | list[dict[str, "tf.Tensor"]] | None]:
        """
        Square pad `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.
        """
        import tensorflow as tf

        x_preprocess = []
        y_preprocess: tf.Tensor | list[dict[str, tf.Tensor]] | None
        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="ImageSquarePadTensorFlowV2", disable=not self.verbose)):
            if self.channels_first:
                x_i = tf.transpose(x_i, (1, 2, 0))

            # Calculate padding
            height, width, _ = x_i.shape
            if height > width:
                pad_top = 0
                pad_bottom = 0
                pad_left = int(np.floor((height - width) / 2))
                pad_right = int(np.ceil((height - width) / 2))
            else:
                pad_top = int(np.floor((width - height) / 2))
                pad_bottom = int(np.ceil((width - height) / 2))
                pad_left = 0
                pad_right = 0

            # Pad image to square size
            padding = [[pad_top, pad_bottom], [pad_left, pad_right], [0, 0]]
            x_pad = tf.pad(x_i, padding, mode=self.pad_mode, **self.pad_kwargs)

            if self.channels_first:
                x_pad = tf.transpose(x_pad, (2, 0, 1))

            if self.clip_values is not None:
                x_pad = tf.clip_by_value(x_pad, self.clip_values[0], self.clip_values[1])

            x_preprocess.append(x_pad)

            if self.label_type == "object_detection" and y is not None:
                y_pad: dict[str, tf.Tensor] = {}

                # Copy labels and ensure types
                if isinstance(y, list) and isinstance(y_preprocess, list):
                    y_i = y[i]
                    if isinstance(y_i, dict):
                        y_pad = {k: tf.identity(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.")

                # Shift bounding boxes
                boxes = y_pad["boxes"]
                boxes += tf.constant([pad_left, pad_top, pad_left, pad_top], dtype=boxes.dtype)
                y_pad["boxes"] = boxes

                y_preprocess.append(y_pad)

        if isinstance(x, tf.Tensor):
            return tf.stack(x_preprocess, axis=0), y_preprocess

        return x_preprocess, y_preprocess

        Square pad `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.
        
art/preprocessing/image/image_square_pad/tensorflow.py