<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stream(self):
 """ Main entry point for the data from the API. Will automatically paginate through the results via the ``next`` token and return up to ``max_results`` tweets or up to ``max_requests`` API calls, whichever is lower. Usage: """

        self.init_session()
        self.check_counts()
        self.execute_request()
        self.stream_started = True
        while True:
            for tweet in self.current_tweets:
                if self.total_results >= self.max_results:
                    break
                yield self._tweet_func(tweet)
                self.total_results += 1

            if self.next_token and self.total_results < self.max_results and self.n_requests <= self.max_requests:
                self.rule_payload = merge_dicts(self.rule_payload,
                                                {"next": self.next_token})
                logger.info("paging; total requests read so far: {}"
                            .format(self.n_requests))
                self.execute_request()
            else:
                break
        logger.info("ending stream at {} tweets".format(self.total_results))
        self.current_tweets = None
        self.session.close()