span class="n">loss_and_metrics</span><span class="p">,</span> <span class="n">to_item</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

        <span class="c1"># Log to wandb</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">logger</span><span class="o">.</span><span class="n">log_metrics</span><sp