'Takes the format returned by DynamoDB and constructs
the appropriate python type.'

def decode(self, attr):

    if ((len(attr) > 1) or (not attr) or is_str(attr)):
        return attr
    dynamodb_type = list(attr.keys())[0]
    if (dynamodb_type.lower() == dynamodb_type):
        return attr
    try:
        decoder = getattr(self, ('_decode_%s' % dynamodb_type.lower()))
    except AttributeError:
        return attr
    return decoder(attr[dynamodb_type])
