<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def transform(self, X):
 """Apply dimensionality reduction on X. X is projected on the first principal components previous extracted from a training set. Parameters X : array-like, shape (n_samples, n_features) New data, where n_samples in the number of samples and n_features is the number of features. Returns ------- X_new : array-like, shape (n_samples, n_components) """

        check_is_fitted(self, ["mean_", "components_"], all_or_any=all)

        # X = check_array(X)
        if self.mean_ is not None:
            X = X - self.mean_
        X_transformed = da.dot(X, self.components_.T)
        if self.whiten:
            X_transformed /= np.sqrt(self.explained_variance_)
        return X_transformed