Can't this be vectorized? Or do you do a for loop to avoid the allocation of an intermediate array with shape of `g_x`? Also the fact that variables names are very similar (`g_x` vs `gx_`) make it hard to read. The following is more readable:

```
for i, gx_i in enumerate(gx):
    g_x[i] = (alpha * (1 - gx_i ** 2)).mean() 
```