human
Complete this python program:
def _load_user_django(path, debug):
assistant
#Here is the Python program you requested.

    """Load the given template using the django found in third_party.
    """
    abspath = os.path.abspath(path)
    if (not debug):
        template = template_cache.get(abspath, None)
    else:
        template = None
    if (not template):
        (directory, file_name) = os.path.split(abspath)
        new_settings = {'TEMPLATE_DIRS': (directory,), 'TEMPLATE_DEBUG': debug, 'DEBUG': debug}
        old_settings = _swap_settings(new_settings)
        try:
            template = django.template.loader.get_template(file_name)
        finally:
            _swap_settings(old_settings)
        if (not debug):
            template_cache[abspath] = template
        def wrap_render(context, orig_render=template.render):
            URLNode = django.template.defaulttags.URLNode
            save_urlnode_render = URLNode.render
            old_settings = _swap_settings(new_settings)
            try:
                URLNode.render = _urlnode_render_replacement
                return orig_render(context)
            finally:
                _swap_settings(old_settings)
                URLNode.render = save_urlnode_render
        template.render = wrap_render
    return template