def __init__(self, train_data, test_data, n_gram=5, if_use=False):
        """
        Calculate Perplexity scores, including forward and reverse.
        PPL-F: PPL_forward, PPL-R: PPL_reverse
        @param train_data: train_data (GenDataIter)
        @param test_data: test_data (GenDataIter)
        @param n_gram: calculate with n-gram
        @param if_use: if use
        """
        super(PPL, self).__init__('[PPL-F, PPL-R]')

        self.n_gram = n_gram
        self.if_use = if_use

        self.gen_tokens = None
        self.train_data = train_data
        self.test_data = test_data

        Calculate Perplexity scores, including forward and reverse.
        PPL-F: PPL_forward, PPL-R: PPL_reverse
        @param train_data: train_data (GenDataIter)
        @param test_data: test_data (GenDataIter)
        @param n_gram: calculate with n-gram
        @param if_use: if use
        
metrics/ppl.py