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

                <span class="c1"># Determine the base name of the image</span>
                <span class="k">if</span> <span class="n">image_ids</span><span class="p">:</span>
                    <span class="n">base_name</span> <span class="o">=</span> <span class="n">image_ids</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span>
                <span class="k">else</span><span class="p">:</span>
                    <span 