<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _fetch_page(cls, api_key, endpoint=None, page_index=0, offset=None, limit=25, **kwargs):
 """ Fetch a single page of `limit` number of results. Optionally provide `page_index` an integer (0-based) index for the page to return. Calculated based on `limit` and `offset`. Optionally provide `offset` which will override `page_index` if both are passed, will be used to calculate the integer offset of items. Optionally provide `limit` integer describing how many items pages ought to have. Returns a tuple containing a list of `cls` instances and response options. """

        # if offset is provided have it overwrite the page_index provided
        if offset is not None:
            page_index = int(offset / limit)

        # limit can be maximum MAX_LIMIT_VALUE for most PD queries
        limit = max(1, min(cls.MAX_LIMIT_VALUE, limit))

        # make an tmp instance to do query work
        inst = cls(api_key=api_key)

        kwargs['offset'] = int(page_index * limit)
        maximum = kwargs.pop('maximum', None)

        # if maximum is valid, make the limit <= maximum
        kwargs['limit'] = min(limit, maximum) if maximum is not None else limit
        ep = parse_key = cls.sanitize_ep(cls.get_endpoint(), plural=True)

        # if an override to the endpoint is provided use that instead
        # this is useful for nested value searches ie. for
        # `incident_log_entries` but instead of /log_entries querying with
        # context of /incident/INCIDENTID/log_entries.
        # XXX: could be cleaner
        if endpoint is not None:
            ep = endpoint

        response = inst.request('GET', endpoint=ep, query_params=kwargs)
        # XXX: this is a little gross right now. Seems like the best way
        # to do the parsing out of something and then return everything else
        datas = cls._parse(response, key=parse_key)
        response.pop(parse_key, None)
        entities = [cls(api_key=api_key, _data=d) for d in datas]
        # return a tuple
        return entities, response