'This function extracts the range of results to consider.
Since MultiQuery dedupes in memory, we must apply the offset and limit in
memory. The results that should be considered are
results[lower_bound:upper_bound].
We also pass the offset=0 and limit=upper_bound to the base queries to
optimize performance.
Args:
config: The base datastore_query.QueryOptions.
Returns:
a tuple consisting of the lower_bound and upper_bound to impose in memory
and the config to use with each bound query. The upper_bound may be None.'

def _ExtractBounds(self, config):

    if (config is None):
        return (0, None, None)
    lower_bound = (config.offset or 0)
    upper_bound = config.limit
    if lower_bound:
        if (upper_bound is not None):
            upper_bound = min((lower_bound + upper_bound), _MAX_INT_32)
        config = datastore_query.QueryOptions(offset=0, limit=upper_bound, config=config)
    return (lower_bound, upper_bound, config)
