<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_latex_template(path_templates, template_filename,
        template_vars=None):
    '''Render a latex template, filling in its template variables

    :param path_templates: the path to the template directory
    :param template_filename: the name, rooted at the path_template_directory,
        of the desired template for rendering
    :param template_vars: dictionary of key:val for jinja2 variables
        defaults to None for case when no values need to be passed
    '''
    var_dict = template_vars if template_vars else {}
    var_dict_escape = recursive_apply(var_dict, escape_latex_str_if_str)
    j2_env = jinja2.Environment(
            loader=jinja2.FileSystemLoader(path_templates), **J2_ARGS
            )
    template = j2_env.get_template(template_filename)
    return template.render(**var_dict_escape)