<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validate_attrs(resource_attr_ids, scenario_id, template_id=None):
 """ Check that multiple resource attribute satisfy the requirements of the types of resources to which the they are attached. """

    multi_rs = db.DBSession.query(ResourceScenario).\
                            filter(ResourceScenario.resource_attr_id.in_(resource_attr_ids),\
                                   ResourceScenario.scenario_id==scenario_id).\
                                   options(joinedload_all("resourceattr")).\
                                   options(joinedload_all("dataset")).all()

    errors = []
    for rs in multi_rs:
        try:
            _do_validate_resourcescenario(rs, template_id)
        except HydraError as e:

            error = dict(
                     ref_key = rs.resourceattr.ref_key,
                     ref_id  = rs.resourceattr.get_resource_id(),
                     ref_name = rs.resourceattr.get_resource().get_name(),
                     resource_attr_id = rs.resource_attr_id,
                     attr_id          = rs.resourceattr.attr.id,
                     attr_name        = rs.resourceattr.attr.name,
                     dataset_id       = rs.dataset_id,
                     scenario_id      = scenario_id,
                     template_id      = template_id,
                     error_text       = e.args[0])

            errors.append(error)

    return errors