<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def request(self, method, path, options=None, payload=None, heartbeater=None, retry_count=0):
 """ Make a request to the Service Registry API. @param method: HTTP method ('POST', 'GET', etc.). @type method: C{str} @param path: Path to be appended to base URL ('/sessions', etc.). @type path: C{str} @param options: Options to be encoded as query parameters in the URL. @type options: C{dict} @param payload: Optional body @type payload: C{dict} @param heartbeater: Optional heartbeater passed in when creating a session. @type heartbeater: L{HeartBeater} """

        def _request(authHeaders, options, payload, heartbeater, retry_count):
            tenantId = authHeaders['X-Tenant-Id']
            requestUrl = self.baseUrl + tenantId + path
            if options:
                requestUrl += '?' + urlencode(options)
            payload = StringProducer(json.dumps(payload)) if payload else None

            d = self.agent.request(method=method,
                                   uri=requestUrl,
                                   headers=None,
                                   bodyProducer=payload)
            d.addCallback(self.cbRequest,
                          method,
                          path,
                          options,
                          payload,
                          heartbeater,
                          retry_count)

            return d

        d = self.agent.getAuthHeaders()
        d.addCallback(_request, options, payload, heartbeater, retry_count)

        return d