src/transformers/generation_logits_process.py/NoBadWordsLogitsProcessor/_tokens_match
class NoBadWordsLogitsProcessor:    def _tokens_match(self, prev_tokens: List[int], tokens: List[int]) -> bool:
        if len(tokens) == 0:
            # if bad word tokens is just one token always ban it
            return True
        elif len(tokens) > len(prev_tokens):
            # if bad word tokens are longer then prev input_ids they can't be equal
            return False
        else:
            return prev_tokens[-len(tokens) :] == tokens