def get_slots(slot_line, utterance, slot_dict):
    """
    Formats slot labels for an utterance. Ensures the multiword 
    slot labels are grouped together. For example the words
    'birthday party' should be grouped together under the 
    same event_name label like event_name(birthday party)
    instead of event_name(birthday), event_name(party).

    """
    # Get slots and their labels
    utterance_words = utterance.split()
    slots_and_labels = []
    prev_slot_label = 'O'
    prev_word_idx = 0
    current_word = ""

    if len(utterance_words) != len(slot_line):
        slot_line = slot_line[1:]

    for word_idx, slot_label_idx in enumerate(slot_line):
        word = utterance_words[word_idx]
        slot_label = slot_dict[int(slot_label_idx)].strip()

        # Only care about words with labels
        if slot_label != 'O':

            # Keep multiword answers together
            if prev_slot_label == slot_label and prev_word_idx == word_idx - 1:
                current_word += " " + word

            # Previous answer has ended and a new one is starting
            else:
                if current_word != "":
                    slots_and_labels.append(f"{prev_slot_label}({current_word})")
                current_word = word

            prev_word_idx = word_idx
            prev_slot_label = slot_label.strip()

    # Add last labeled word to list of slots and labels if the utterance is over
    if current_word != "" and prev_slot_label != 'O':
        slots_and_labels.append(f"{prev_slot_label}({current_word})")

    # Format slot labels
    if not slots_and_labels:
        slot_labels = "None"
    else:
        slot_labels = ", ".join(slots_and_labels)

    return slot_labels