def _block_idct(self, x, block_size=8, masked=False, ratio=0.5):
        """
        Applies IDCT to each block of size block_size.

        :param x: An array with the inputs to be attacked.
        :param block_size: block size for DCT attacks.
        :param masked: use the mask.
        :param ratio: Ratio of the lowest frequency directions in order to make the adversarial perturbation in the low
                      frequency space.

        :return var_z: An array holding the order of DCT attacks.
        """
        if not self.estimator.channels_first:
            x = x.transpose(0, 3, 1, 2)
        var_z = np.zeros(x.shape).astype(ART_NUMPY_DTYPE)
        num_blocks = int(x.shape[2] / block_size)
        mask = np.zeros((x.shape[0], x.shape[1], block_size, block_size))
        if not isinstance(ratio, float):
            for i in range(x.shape[0]):
                mask[i, :, : int(block_size * ratio[i]), : int(block_size * ratio[i])] = 1
        else:
            mask[:, :, : int(block_size * ratio), : int(block_size * ratio)] = 1
        for i in range(num_blocks):
            for j in range(num_blocks):
                submat = x[:, :, (i * block_size) : ((i + 1) * block_size), (j * block_size) : ((j + 1) * block_size)]
                if masked:
                    submat = submat * mask
                var_z[:, :, (i * block_size) : ((i + 1) * block_size), (j * block_size) : ((j + 1) * block_size)] = (
                    idct(idct(submat, axis=3, norm="ortho"), axis=2, norm="ortho")
                )

        if self.estimator.channels_first:
            return var_z

        return var_z.transpose((0, 2, 3, 1))

        Applies IDCT to each block of size block_size.

        :param x: An array with the inputs to be attacked.
        :param block_size: block size for DCT attacks.
        :param masked: use the mask.
        :param ratio: Ratio of the lowest frequency directions in order to make the adversarial perturbation in the low
                      frequency space.

        :return var_z: An array holding the order of DCT attacks.
        
art/attacks/evasion/simba.py