<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(template=None, filepath=None, context=None, at_paths=None, at_encoding=anytemplate.compat.ENCODING, at_engine=None, at_ask_missing=False, at_cls_args=None, _at_usr_tmpl=None, **kwargs):
 """ Compile and render given template string and return the result string. :param template: Template content string or None :param filepath: Template file path or None :param context: A dict or dict-like object to instantiate given template file :param at_paths: Template search paths :param at_encoding: Template encoding :param at_engine: Specify the name of template engine to use explicitly or None to find it automatically anyhow. :param at_cls_args: Arguments passed to instantiate template engine class :param _at_usr_tmpl: Template file of path will be given by user later; this file will be used just for testing purpose. :param kwargs: Keyword arguments passed to the template engine to render templates with specific features enabled. :return: Rendered string """

    ecls = find_engine(filepath, at_engine)
    LOGGER.debug("Use the template engine: %s", ecls.name())
    engine = ecls() if at_cls_args is None else ecls(**at_cls_args)
    at_paths = anytemplate.utils.mk_template_paths(filepath, at_paths)

    if filepath is None:
        (render_fn, target) = (engine.renders, template)
    else:
        (render_fn, target) = (engine.render, filepath)

    try:
        return render_fn(target, context=context, at_paths=at_paths,
                         at_encoding=at_encoding, **kwargs)
    except TemplateNotFound as exc:
        LOGGER.warning("** Missing template[s]: paths=%r", at_paths)
        if not at_ask_missing:
            raise TemplateNotFound(str(exc))

        if _at_usr_tmpl is None:
            _at_usr_tmpl = anytemplate.compat.raw_input(
                "\nPlease enter an absolute or relative path starting "
                "from '.' of missing template file"
                "%s : " % (", " + filepath if template is None else '')
            ).strip()

        usr_tmpl = anytemplate.utils.normpath(_at_usr_tmpl)
        if template is None:
            LOGGER.debug("Render %s instead of %s", usr_tmpl, filepath)
            target = usr_tmpl

        return render_fn(target, context=context,
                         at_paths=(at_paths + [os.path.dirname(usr_tmpl)]),
                         at_encoding=at_encoding, **kwargs)
    except Exception as exc:
        raise CompileError("exc=%r, template=%s" % (exc, target[:200]))