def _preprocess_images(images):
    """
    Converts MNIST images from (?, 28, 28, 1) to (?, 784) and normalizes pixel
    values from [0, 255] grayscale to a [0, 1] representation.
    """
    images = images / 255.0
    images = images.reshape(images.shape[0], 784)
    images = images.astype("float32")
    assert images.shape[1] == 784
    return images