def mutual_info(word):
    """
    Finds the mutual information of a word with the training set.
    """
    cnt_p, cnt_n = sums['pos'], sums['neg']
    total = cnt_n + cnt_p
    cnt_x = positive[word] + negative[word]
    if (cnt_x == 0): 
        return 0
    cnt_x_p, cnt_x_n = positive[word], negative[word]
    I = [[0]*2]*2
    I[0][0] = (cnt_n - cnt_x_n) * log ((cnt_n - cnt_x_n) * total / cnt_x / cnt_n) / total 
    I[0][1] = cnt_x_n * log ((cnt_x_n) * total / (cnt_x * cnt_n)) / total if cnt_x_n > 0 else 0
    I[1][0] = (cnt_p - cnt_x_p) * log ((cnt_p - cnt_x_p) * total / cnt_x / cnt_p) / total 
    I[1][1] = cnt_x_p * log ((cnt_x_p) * total / (cnt_x * cnt_p)) / total if cnt_x_p > 0 else 0

    return sum(map(sum, I))

    Finds the mutual information of a word with the training set.
    
pretrained.py