span class="p">)</span>

            <span class="c1"># Calculate loss for the batch</span>
            <span class="n">loss</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">loss_function</span><span class="p">(</span><span class="n">y_pred</span><span class="p">,</span> <span class="n">y_train_batch</span><span class="p">)</span>

            <span class="c1"># Perform backward pass</span>
            <span class="n">loss</span><span class="o">.</span><spa