<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_attribute_by_name_and_dimension(name, dimension_id=None,**kwargs):
 """ Get a specific attribute by its name. dimension_id can be None, because in attribute the dimension_id is not anymore mandatory """

    try:
        attr_i = db.DBSession.query(Attr).filter(and_(Attr.name==name, Attr.dimension_id==dimension_id)).one()
        log.debug("Attribute retrieved")
        return attr_i
    except NoResultFound:
        return None