def widget_html(site_key, theme=None, type_=None):
    """
    Return the HTML code for the reCAPTCHA widget.

    :param site_key: Site key
    :param theme: Theme, may be "dark" or "light" (optional)
    :param type_: Data type, may be "image" or "audio" (optional)
    :return: HTML code
    """

    attrs = {'data-sitekey': site_key}
    s = '<div class="g-recaptcha" {attrs}></div>'

    if theme:
        if theme not in ('light', 'dark'):
            raise ValueError('theme must be "light" or "dark"')
        attrs['data-theme'] = theme

    if type_:
        if type_ not in ('image', 'audio'):
            raise ValueError('type_ must be "image" or "audio"')
        attrs['data-type'] = type_

    return s.format(attrs=' '.join(['{}="{}"'.format(k, v) for k, v in attrs.items()]))