ass="p">(</span><span class="mf">1e-12</span><span class="p">,</span> <span class="n">grad</span><span class="o">.</span><span class="n">dtype</span><span class="p">)</span>
      <span class="n">grad</span> <span class="o">=</span> <span class="n">grad</span> <span class="o">/</span> <span class="n">tf</span><span class="o">.</span><span class="n">maximum</span><span class="p">(</span>
          <span class="n">avoid_zero_div</span><span class="p">,</span>
          <span class="n">reduce_mean</span><span 