I'm trying various ways to normalize array sum to 1, but it fails. E.g. the following code fails on Intel CPU and also Colab:
import numpy as np
a = 0.99
choice = 0
g = np.ones((9,)) * (1.0 - a)/8
g[choice] = a
print(np.sum(g), g)
g = g / np.sum(g)
print(np.sum(g), g)
assert(np.sum(g) == 1.0)