<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def device_id_partition_keygen(request_envelope):
 # type: (RequestEnvelope) -> str """Retrieve device id from request envelope, to use as partition key. :param request_envelope: Request Envelope passed during skill invocation :type request_envelope: ask_sdk_model.RequestEnvelope :return: Device Id retrieved from request envelope :rtype: str :raises: :py:class:`ask_sdk_core.exceptions.PersistenceException` """

    try:
        device_id = request_envelope.context.system.device.device_id
        return device_id
    except AttributeError:
        raise PersistenceException("Couldn't retrieve device id from "
                                   "request envelope, for partition key use")