def forward(
        self, x: "torch.Tensor", y: "torch.Tensor" | None = None
    ) -> tuple["torch.Tensor", "torch.Tensor" | None]:
        """
        Apply MP3 compression to sample `x`.

        :param x: Sample to compress with shape `(length, channel)` or an array of sample arrays with shape
                  (length,) or (length, channel).
        :param y: Labels of the sample `x`. This function does not affect them in any way.
        :return: Compressed sample.
        """
        import torch

        ndim = x.ndim

        if ndim == 1:
            x = torch.unsqueeze(x, dim=0)
            if self.channels_first:
                dim = 1
            else:
                dim = 2
            x = torch.unsqueeze(x, dim=dim)

        x_compressed = self._compression_pytorch_numpy.apply(x)

        if ndim == 1:
            x_compressed = torch.squeeze(x_compressed)

        return x_compressed, y

        Apply MP3 compression to sample `x`.

        :param x: Sample to compress with shape `(length, channel)` or an array of sample arrays with shape
                  (length,) or (length, channel).
        :param y: Labels of the sample `x`. This function does not affect them in any way.
        :return: Compressed sample.
        
art/defences/preprocessor/mp3_compression_pytorch.py