N = len(z)
a = 0
ez_sum = 0
ez = np.exp(z)
for k in range(N):
ez_sum = ez_sum + np.sum(ez[k])
for j in range(N):
a[j] = ez[j] / ez_sum
a = a[j]
return a

I tried avoiding the for loops, however, despite of obtaining correct values at the output, an error for the wrong values at the output was appeared. This is why I used for loops again.