span class="k">as</span> <span class="n">e</span><span class="p">:</span>
            <span class="n">prepend_exception_msg</span><span class="p">(</span><span class="n">e</span><span class="p">,</span> <span class="s1">'Error in process_samples_function callback'</span><span class="p">)</span>
            <span class="k">raise</span>

    <span class="c1"># Clamp the max sample per class if specified</span>
    <span class="k">if</span> <span class="n">max_samples_per_class</span> <span class="o">!=</span>