def _need_check_tokens(self):
if self.n_tokens <= <NUM_LIT:1> or self.rate_limit is None:<EOL><INDENT>return False<EOL><DEDENT>elif self.last_rate_limit_checked is None:<EOL><INDENT>self.last_rate_limit_checked = self.rate_limit<EOL>return True<EOL><DEDENT>approaching_limit = float(self.min_rate_to_sleep) * (<NUM_LIT:1.0> + TOKEN_USAGE_BEFORE_SWITCH) + <NUM_LIT:1><EOL>if self.rate_limit <= approaching_limit:<EOL><INDENT>self.last_rate_limit_checked = self.rate_limit<EOL>return True<EOL><DEDENT>ratio = float(self.rate_limit) / float(self.last_rate_limit_checked)<EOL>if ratio < <NUM_LIT:1.0> - TOKEN_USAGE_BEFORE_SWITCH:<EOL><INDENT>self.last_rate_limit_checked = self.rate_limit<EOL>return True<EOL><DEDENT>elif ratio > <NUM_LIT:1.0>:<EOL><INDENT>self.last_rate_limit_checked = self.rate_limit<EOL>return False<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>
Check if we need to switch GitHub API tokens