{% if typed_dict.has_both() -%}
    {{ '_Required' -}}
    {{ typed_dict.name -}}
    {{ ' = TypedDict("' -}}
    {{ '_Required' -}}
    {{ typed_dict.name -}}
    {{ '", {' -}}
    {% for child in typed_dict.get_required() -%}
        {{ '"' -}}
        {{ child.name -}}
        {{ '": ' -}}
        {{ child.type_annotation -}}
        {{ ", " if not loop.last else "" -}}
    {% endfor -%}
    {{ "})\n" -}}
    {{ '_Optional' -}}
    {{ typed_dict.name -}}
    {{ ' = TypedDict("' -}}
    {{ '_Optional' -}}
    {{ typed_dict.name -}}
    {{ '", {' -}}
    {% for child in typed_dict.get_optional() -%}
        {{ '"' -}}
        {{ child.name -}}
        {{ '": ' -}}
        {{ child.type_annotation -}}
        {{ ", " if not loop.last else "" -}}
    {% endfor -%}
    {{ "}, total=False)\n" -}}

    {{ 'class ' -}}
    {{ typed_dict.name -}}
    {{ "(" -}}
    {{ '_Required' -}}
    {{ typed_dict.name -}}
    {{ ", " -}}
    {{ '_Optional' -}}
    {{ typed_dict.name -}}
    {{ ")" -}}
    {{ ':\n' -}}
    {% filter indent(4, True) -%}
        {% if typed_dict.docstring -%}
            {{ '"""\n' -}}
            {{ typed_dict.docstring -}}
            {{ '\n' -}}
            {{ '"""\n' -}}
        {% else -%}
            {{ "    pass\n" -}}
        {% endif -%}
    {% endfilter -%}
{% else -%}
    {{ '_' -}}
    {{ typed_dict.name -}}
    {{ ' = TypedDict("' -}}
    {{ '_' -}}
    {{ typed_dict.name -}}
    {{ '", {' -}}
    {% for child in typed_dict.children -%}
        {{ '"' -}}
        {{ child.name -}}
        {{ '": ' -}}
        {{ child.type_annotation -}}
        {{ ", " if not loop.last else "" -}}
    {% endfor -%}
    {{ "}" -}}
    {% if typed_dict.has_optional() -%}
        {{ ", total=False" -}}
    {% endif -%}
    {{ ")\n" -}}

    {{ 'class ' -}}
    {{ typed_dict.name -}}
    {{ "(" -}}
    {{ '_' -}}
    {{ typed_dict.name -}}
    {{ ")" -}}
    {{ ':\n' -}}
    {% filter indent(4, True) -%}
        {% if typed_dict.docstring -%}
            {{ '"""\n' -}}
            {{ typed_dict.docstring -}}
            {{ '\n' -}}
            {{ '"""\n' -}}
        {% else -%}
            {{ "    pass\n" -}}
        {% endif -%}
    {% endfilter -%}
{% endif -%}