def find_matching_template(question, templates):
    """Return the template that corresponds to the given question"""
    for t in templates.values():
        for r in t["regexes"]:
            if r.fullmatch(question["question"]) is not None:
                return t
    assert False, "No template found"