def normalize_image(x):
    """
    Normalize an image so its values are between 0.0 and 1.0. This is useful
    for plotting the gradient.
    """
    # Get the min and max values for all pixels in the input.
    x_min = x.min()
    x_max = x.max()

    # Normalize so all values are between 0.0 and 1.0
    x_norm = (x - x_min) / (x_max - x_min)

    return x_norm