<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _generate_url(self, resource, query_params=None):
 """ Build the url to resource. :param resource: Name of the resource that is being called. Options are `''` (empty string) for root resource, `'parser'`, `'confidence'`. :param query_params: Data to be passed as query parameters. """

        resource = '{resource}?token={token}'.format(resource=resource, token=self.token)
        if query_params:
            resource += "&{}".format(urlencode(query_params))
        return self.base_url_template.format(resource)