(self, timestep, k, requires_attn=True)
return hyp[::-1], attn
Walk back to construct the full hypothesis.
Walk back to construct the full hypothesis.
Walk back to construct the full hypothesis .
def get_hyp(self, timestep, k, requires_attn=True):
        """
        Walk back to construct the full hypothesis.
        """
        hyp, attn = [], []
        for j in range(len(self.prev_ks[:timestep]) - 1, -1, -1):
            hyp.append(self.next_ys_cpu[j + 1][k])
            if requires_attn:
                attn.append(self.attn[j][k])
            k = self.prev_ks_cpu[j][k]

        if requires_attn:
            attn = torch.stack(attn[::-1])
        return hyp[::-1], attn
def get_hyp ( self , timestep , k , requires_attn = True ) : hyp , attn = [ ] , [ ] for j in range ( len ( self . prev_ks [ : timestep ] ) - 1 , - 1 , - 1 ) : hyp . append ( self . next_ys_cpu [ j + 1 ] [ k ] ) if requires_attn : attn . append ( self . attn [ j ] [ k ] ) k = self . prev_ks_cpu [ j ] [ k ] if requires_attn : attn = torch . stack ( attn [ : : - 1 ] ) return hyp [ : : - 1 ] , attn