def transform_images(X, max_x_value=255):
    """Flatten and rescale input."""
    # Divide by a fixed value to be sure that we are making the same
    # transformation on training and test data.
    return X.reshape(X.shape[0], -1) / max_x_value