<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def render_attrs(attrs):
 """ Render HTML attributes, or return '' if no attributes needs to be rendered. """

    if attrs is not None:
        def parts():
            for key, value in sorted(attrs.items()):
                if value is None:
                    continue
                if value is True:
                    yield '%s' % (key, )
                    continue
                if key == 'class' and isinstance(value, dict):
                    if not value:
                        continue
                    value = render_class(value)
                if key == 'style' and isinstance(value, dict):
                    if not value:
                        continue
                    value = render_style(value)
                yield '%s="%s"' % (key, ('%s' % value).replace('"', '&quot;'))
        return mark_safe(' %s' % ' '.join(parts()))
    return ''