{% with id=widget.attrs.id|default:None %}
    {% for _, options, _ in tr.optgroups %}
        {% for option in options %}
            <td{% if id %} id="{{ id }}"{% endif %}>{% include option.template_name with widget=option %} </td>
        {% endfor %}
    {% endfor %}
{% endwith %}
