<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def as_device(self):
 """Convert to a `Device` object. `node_type` must be `NodeType.DEVICE`. """

        if self.node_type != NodeType.DEVICE:
            raise ValueError(
                'Cannot convert to `Device`, node_type is not a device.')
        return self._origin.Device(self._data)