def METHOD_NAME(
    tracker: DialogueStateTracker, number_of_last_intent_names: int
) -> List[Optional[Text]]:
    intent_names: List[Optional[Text]] = []
    for i in range(number_of_last_intent_names):
        message = tracker.get_last_event_for(
            (UserUttered, UserUtteranceReverted),
            skip=i,
            event_verbosity=EventVerbosity.AFTER_RESTART,
        )
        if isinstance(message, UserUttered):
            intent_names.append(message.intent.get("name"))
    return intent_names