def forward(self, x: "tf.Tensor", y: "tf.Tensor" | None = None) -> tuple["tf.Tensor", "tf.Tensor" | None]:
        """
        Apply Cutout data augmentation to sample `x`.

        :param x: Sample to cut out with shape of `NCHW`, `NHWC`, `NCFHW` or `NFHWC`.
                  `x` values are expected to be in the data range [0, 1] or [0, 255].
        :param y: Labels of the sample `x`. This function does not affect them in any way.
        :return: Data augmented sample.
        """
        import tensorflow as tf  # lgtm [py/repeated-import]
        import tensorflow_addons as tfa

        x_ndim = len(x.shape)

        # NCHW/NCFHW/NFHWC --> NHWC
        if x_ndim == 4:
            if self.channels_first:
                # NCHW --> NHWC
                x_nhwc = tf.transpose(x, (0, 2, 3, 1))
            else:
                # NHWC
                x_nhwc = x
        elif x_ndim == 5:
            if self.channels_first:
                # NCFHW --> NFHWC --> NHWC
                nb_clips, channels, clip_size, height, width = x.shape
                x_nfhwc = tf.transpose(x, (0, 2, 3, 4, 1))
                x_nhwc = tf.reshape(x_nfhwc, (nb_clips * clip_size, height, width, channels))
            else:
                # NFHWC --> NHWC
                nb_clips, clip_size, height, width, channels = x.shape
                x_nhwc = tf.reshape(x, (nb_clips * clip_size, height, width, channels))
        else:
            raise ValueError("Unrecognized input dimension. Cutout can only be applied to image and video data.")

        # round down length to be divisible by 2
        length = self.length if self.length % 2 == 0 else max(self.length - 1, 2)

        # apply random cutout
        x_nhwc = tfa.image.random_cutout(x_nhwc, (length, length))

        # NCHW/NCFHW/NFHWC <-- NHWC
        if x_ndim == 4:
            if self.channels_first:
                # NHWC <-- NCHW
                x_aug = tf.transpose(x_nhwc, (0, 3, 1, 2))
            else:
                # NHWC
                x_aug = x_nhwc
        elif x_ndim == 5:  # lgtm [py/redundant-comparison]
            if self.channels_first:
                # NCFHW <-- NFHWC <-- NHWC
                x_nfhwc = tf.reshape(x_nhwc, (nb_clips, clip_size, height, width, channels))
                x_aug = tf.transpose(x_nfhwc, (0, 4, 1, 2, 3))
            else:
                # NFHWC <-- NHWC
                x_aug = tf.reshape(x_nhwc, (nb_clips, clip_size, height, width, channels))

        return x_aug, y

        Apply Cutout data augmentation to sample `x`.

        :param x: Sample to cut out with shape of `NCHW`, `NHWC`, `NCFHW` or `NFHWC`.
                  `x` values are expected to be in the data range [0, 1] or [0, 255].
        :param y: Labels of the sample `x`. This function does not affect them in any way.
        :return: Data augmented sample.
        
art/defences/preprocessor/cutout/cutout_tensorflow.py