def __call__(self, x: np.ndarray, y: np.ndarray | None = None) -> tuple[np.ndarray, np.ndarray | None]:
        """
        Apply thermometer encoding to sample `x`. The new axis with the encoding is added as last dimension.

        :param x: Sample to encode with shape `(batch_size, width, height, depth)`.
        :param y: Labels of the sample `x`. This function does not affect them in any way.
        :return: Encoded sample with shape `(batch_size, width, height, depth x num_space)`.
        """
        # First normalize the input to be in [0, 1]:
        np.clip(x, self.clip_values[0], self.clip_values[1], out=x)
        x = (x - self.clip_values[0]) / (self.clip_values[1] - self.clip_values[0])

        # Now apply the encoding:
        channel_index = 1 if self.channels_first else x.ndim - 1
        result = np.apply_along_axis(self._perchannel, channel_index, x)
        np.clip(result, 0, 1, out=result)
        return result.astype(ART_NUMPY_DTYPE), y

        Apply thermometer encoding to sample `x`. The new axis with the encoding is added as last dimension.

        :param x: Sample to encode with shape `(batch_size, width, height, depth)`.
        :param y: Labels of the sample `x`. This function does not affect them in any way.
        :return: Encoded sample with shape `(batch_size, width, height, depth x num_space)`.
        
art/defences/preprocessor/thermometer_encoding.py