human
Give me a the Python program you requested given the following:
I am working on the file "3_tv-script-generation/dlnd_tv_script_generation.ipynb".
The first task is:
Choose Word
Implement the pick_word() function to select the next word using probabilities.
Can you write Python program for it?
assistant
#Here is the Python program you requested.

def pick_word(probabilities, int_to_vocab):
    """
    Pick the next word in the generated text
    :param probabilities: Probabilites of the next word
    :param int_to_vocab: Dictionary of word ids as the keys and words as the values
    :return: String of the predicted word
    """
    def throw_the_dice(words):
        # filter out some words based on their probability
        return [word for prob, (_, word) in words if prob >= np.random.rand()]
    
    k = 10
    vocab = sorted(zip(probabilities, int_to_vocab.items()), reverse=True)
    words = vocab[:k]
    
    leftover_words = []
    while not leftover_words:
        # Keep trying until we have at least one word that was not filter out
        leftover_words = throw_the_dice(words)
    
    return leftover_words[0]

"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_pick_word(pick_word)