(self, memory_bank)
return sent_output
This is the sentence level encoder, it takes a bunch of sentence encoding,
        then feed into another sentence level rnn
        :param memory_bank: sentence encoding ( a list of packed)
        :return: output of the rnn layer
This is the sentence level encoder, it takes a bunch of sentence encoding,
        then feed into another sentence level rnn
        :param memory_bank: sentence encoding ( a list of packed)
        :return: output of the rnn layer
This is the sentence level encoder it takes a bunch of sentence encoding then feed into another sentence level rnn : param memory_bank : sentence encoding ( a list of packed ) : return : output of the rnn layer
def sent_level_encoder(self, memory_bank):
        '''
        This is the sentence level encoder, it takes a bunch of sentence encoding,
        then feed into another sentence level rnn
        :param memory_bank: sentence encoding ( a list of packed)
        :return: output of the rnn layer
        '''

        if isinstance(memory_bank, torch.nn.utils.rnn.PackedSequence):
            memory_bank_unpacked = nn.utils.rnn.pad_packed_sequence(memory_bank)[0].permute(1,0,2)# as after unpack it is a tuple
        # memory_bank_unpacked size: torch.Size([42, 9, 512]) # [seq_len,batch_size,512]


        # take the last hiddent state of each
        last_hidden = [x[-1].unsqueeze(0) for x in memory_bank_unpacked]
        last_hidden = torch.cat(last_hidden, 0).unsqueeze(0) # size is [1,9,512]

        sent_output, (h_, c_) = self.sent_rnn(last_hidden)


        return sent_output
def sent_level_encoder ( self , memory_bank ) : if isinstance ( memory_bank , torch . nn . utils . rnn . PackedSequence ) : memory_bank_unpacked = nn . utils . rnn . pad_packed_sequence ( memory_bank ) [ 0 ] . permute ( 1 , 0 , 2 ) # as after unpack it is a tuple # memory_bank_unpacked size: torch.Size([42, 9, 512]) # [seq_len,batch_size,512] # take the last hiddent state of each last_hidden = [ x [ - 1 ] . unsqueeze ( 0 ) for x in memory_bank_unpacked ] last_hidden = torch . cat ( last_hidden , 0 ) . unsqueeze ( 0 ) # size is [1,9,512] sent_output , ( h_ , c_ ) = self . sent_rnn ( last_hidden ) return sent_output