AttributeError: 'tuple' object has no attribute 'device'