</span><span class="n">loss</span>

      <span class="c1"># Define gradient of loss wrt input</span>
      <span class="n">grad</span><span class="p">,</span> <span class="o">=</span> <span class="n">tf</span><span class="o">.</span><span class="n">gradients</span><span class="p">(</span><span class="n">loss</span><span class="p">,</span> <span class="n">ax</span><span class="p">)</span>

      <span class="c1"># Normalize current gradient and add it to the accumulated gradient</span>
      <span class="n"