code: def parse_reply(self, data):
          
          if isinstance(data, bytes):
              data = data.decode()
  
          try:
              rep = json.loads(data)
          except Exception as e:
              raise InvalidReplyError(e)
  
          for k in rep.keys():
              if not k in self._ALLOWED_REPLY_KEYS:
                  raise InvalidReplyError('Key not allowed: %s' % k)
  
          if 'jsonrpc' not in rep:
              raise InvalidReplyError('Missing jsonrpc (version) in response.')
  
          if rep['jsonrpc'] != self.JSON_RPC_VERSION:
              raise InvalidReplyError('Wrong JSONRPC version')
  
          if 'id' not in rep:
              raise InvalidReplyError('Missing id in response')
  
          if ('error' in rep) and ('result' in rep):
              raise InvalidReplyError(
                  'Reply must contain exactly one of result and error.'
              )
  
          if 'error' in rep:
              response = JSONRPCErrorResponse()
              error = rep['error']
              response.error = error["message"]
              response._jsonrpc_error_code = error["code"]
              if "data" in error:
                  response.data = error["data"]
          else:
              response = JSONRPCSuccessResponse()
              response.result = rep.get('result', None)
  
          response.unique_id = rep['id']
  
          return response
docs: Deserializes and validates a response.
  
          Called by the client to reconstruct the serialized :py:class:`JSONRPCResponse`.
  
          :param bytes data: The data stream received by the transport layer containing the
              serialized request.
          :return: A reconstructed response.
          :rtype: :py:class:`JSONRPCSuccessResponse` or :py:class:`JSONRPCErrorResponse`
          :raises InvalidReplyError: if the response is not valid JSON or does not conform
              to the standard.