<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query_keys(self, user_devices, timeout=None, token=None):
 """Query HS for public keys by user and optionally device. Args: user_devices (dict):
 The devices whose keys to download. Should be formatted as <user_id>: [<device_ids>]. No device_ids indicates all devices for the corresponding user. timeout (int):
 Optional. The time (in milliseconds) to wait when downloading keys from remote servers. token (str):
 Optional. If the client is fetching keys as a result of a device update received in a sync request, this should be the 'since' token of that sync request, or any later sync token. """

        content = {"device_keys": user_devices}
        if timeout:
            content["timeout"] = timeout
        if token:
            content["token"] = token
        return self._send("POST", "/keys/query", content=content)