<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def send_email(template_name, context=None, *args, **kwargs):
 """ Send a templated email. To generate the message used for the email, the method first searches for an HTML template with the given name (eg: <template>.html), and renders it with the provided context. The process is repeated for the plain text message except a 'txt' extension is used. All other options are forwarded to Django's ``send_mail`` function. Args: template_name: The name of the template to use without an extension. The extensions ``html`` and ``txt`` are appended to the template name and then rendered to provide the email content. context: A dictionary containing the context to render the message with. Defaults to an empty dictionary. Returns: ``1`` if the email is succesfully sent and ``0`` otherwise. The return values come from Django's ``send_mail`` function. Throws: NoTemplatesException: If neither the HTML nor plain text template can be loaded. """

    context = context or {}

    try:
        html = render_to_string(
            context=context,
            template_name='{}.html'.format(template_name),
        )
    except TemplateDoesNotExist:
        html = ''

    try:
        text = render_to_string(
            context=context,
            template_name='{}.txt'.format(template_name),
        )
    except TemplateDoesNotExist:
        text = ''

    if not html and not text:
        raise NoTemplatesException(template_name)

    return mail.send_mail(
        *args,
        html_message=html,
        message=text,
        **kwargs
    )