<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter_formatter(kwargs, attr_map):
 """Builds a filter according to the cross-api specification :param kwargs: expected to contain {'filter': {filter dict}} :returns: {validated filter dict} """

    params = _depluralise_filters_key(copy.copy(kwargs))
    params.update(_get_filter(sdk_filter=params.pop('filter', {}), attr_map=attr_map))
    return params