@staticmethod
def parse_attr(attr_proto):
    """Convert a list of AttributeProto to a dict, with names as keys."""
    attrs = {}
    for a in attr_proto:
        for f in ['f', 'i', 's']:
            if a.HasField(f):
                attrs[a.name] = getattr(a, f)
        for f in ['floats', 'ints', 'strings']:
            if list(getattr(a, f)):
                assert a.name not in attrs, 'Only one type of attr is allowed'
                attrs[a.name] = tuple(getattr(a, f))
        for f in ['t', 'g']:
            if a.HasField(f):
                attrs[a.name] = getattr(a, f)
        for f in ['tensors', 'graphs']:
            if list(getattr(a, f)):
                raise NotImplementedError('Filed {} is not supported in mxnet.'
                    .format(f))
        if a.name not in attrs:
            raise ValueError('Cannot parse attribute: \n{}\n.'.format(a))
    return attrs
