code: def filter_attribute_value_assertions(ava, attribute_restrictions=None):
      
      if not attribute_restrictions:
          return ava
  
      for attr, vals in list(ava.items()):
          _attr = attr.lower()
          try:
              _rests = attribute_restrictions[_attr]
          except KeyError:
              del ava[attr]
          else:
              if _rests is None:
                  continue
              if isinstance(vals, six.string_types):
                  vals = [vals]
              rvals = []
              for restr in _rests:
                  for val in vals:
                      if restr.match(val):
                          rvals.append(val)
  
              if rvals:
                  ava[attr] = list(set(rvals))
              else:
                  del ava[attr]
      return ava
docs: Will weed out attribute values and values according to the
      rules defined in the attribute restrictions. If filtering results in
      an attribute without values, then the attribute is removed from the
      assertion.
  
      :param ava: The incoming attribute value assertion (dictionary)
      :param attribute_restrictions: The rules that govern which attributes
          and values that are allowed. (dictionary)
      :return: The modified attribute value assertion