def get_word_freq_per_utt(trans_f):
    """ Get word frequency per utterance in nested dict format """

    # nested dict {key_word_1: {utt_id_1: count, utt_id_2: count, ...},
    #              key_word_2: {utt_id_1: count, utt_id_2: count, ...},
    #              ...
    #             }
    w_freq = {}
    with open(trans_f, "r", encoding="utf-8") as fpr:
        for line in fpr:
            tokens = line.strip().split()
            utt_id = tokens[0]
            for tok in tokens[1:]:
                utt_freq = {}
                if tok in w_freq:
                    utt_freq = w_freq[tok]

                try:
                    utt_freq[utt_id] += 1
                except KeyError:
                    utt_freq[utt_id] = 1

                w_freq[tok] = utt_freq

    return w_freq