I was implementing Sharpness Aware Minimization (SAM) using Tensorflow. The algorithm is simplified as follows