<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def gen_request(self, request_type="json", token=None, set_batch=False, batch_onerror=None):
 """ Convenience method to quickly generate a token :param request_type: Type of request (defaults to json) :param token: Authentication token :param set_batch: Also set this request to batch mode? :param batch_onerror: Onerror-parameter for batch mode :return: The request """


        if request_type == "json":

            local_request = RequestJson()

        elif request_type == "xml":

            local_request = RequestXml()

        else:

            raise UnknownRequestType()

        if token is not None:
            local_request.set_auth_token(token)

        if set_batch:
            local_request.enable_batch(batch_onerror)

        return local_request