human
Complete this python program:
def _send_bulk_mail(recipient_ids, sender_id, intent, email_subject, email_html_body, sender_email, sender_name, instance_id=None):
assistant
#Here is the Python code you requested.

    """Sends an email to all given recipients.
    Args:
    recipient_ids: list(str). The user IDs of the email recipients.
    sender_id: str. The ID of the user sending the email.
    intent: str. The intent string, i.e. the purpose of the email.
    email_subject: str. The subject of the email.
    email_html_body: str. The body (message) of the email.
    sender_email: str. The sender\s email address.
    sender_name: str. The name to be shown in the "sender" field of the
    email.
    instance_id: str or None. The ID of the BulkEmailModel entity instance.
    """
    _require_sender_id_is_valid(intent, sender_id)
    recipients_settings = user_services.get_users_settings(recipient_ids)
    recipient_emails = [user.email for user in recipients_settings]
    cleaned_html_body = html_cleaner.clean(email_html_body)
    if (cleaned_html_body != email_html_body):
        log_new_error(('Original    email    HTML    body    does    not    match    cleaned    HTML    body:\nOriginal:\n%s\n\nCleaned:\n%s\n' % (email_html_body, cleaned_html_body)))
        return
    raw_plaintext_body = cleaned_html_body.replace('<br/>', '\n').replace('<br>', '\n').replace('<li>', '<li>-    ').replace('</p><p>', '</p>\n<p>')
    cleaned_plaintext_body = html_cleaner.strip_html_tags(raw_plaintext_body)
    def _send_bulk_mail_in_transaction(instance_id=None):
        sender_name_email = ('%s    <%s>' % (sender_name, sender_email))
        email_services.send_bulk_mail(sender_name_email, recipient_emails, email_subject, cleaned_plaintext_body, cleaned_html_body)
        if (instance_id is None):
            instance_id = email_models.BulkEmailModel.get_new_id('')
        email_models.BulkEmailModel.create(instance_id, recipient_ids, sender_id, sender_name_email, intent, email_subject, cleaned_html_body, datetime.datetime.utcnow())
    return transaction_services.run_in_transaction(_send_bulk_mail_in_transaction, instance_id)