public double viterbiSearchBackward(DataSequence dataSeq, double lambda[], DoubleMatrix2D Mis[], DoubleMatrix1D Ris[], boolean calcCorrectScore) {
        if ((Mi == null)||(winningLabel==null)) {
            allocateScratch(model.numY);
        }
        if ((winningLabel[0] == null) || (winningLabel[0].length < dataSeq.length())) {
            for (int yi = 0; yi < winningLabel.length; yi++) {
                winningLabel[yi] = new Entry[dataSeq.length()];
                for (int l = 0; l < dataSeq.length(); l++)
                    winningLabel[yi][l] = new Entry(beamsize, yi, l);
            }
        }
        Entry firstEntries[] = new Entry[model.numY];
        for (int yi = 0; yi < winningLabel.length; yi++) {
            firstEntries[yi] = new Entry(1, yi, 0);	
        }
        double corrScore = fillArrayBackward(dataSeq, lambda,firstEntries, Mis, Ris, calcCorrectScore);
        
        finalSoln.clear();
        finalSoln.valid = true;
        for (int yi = 0; yi < model.numY; yi++) {
            finalSoln.add(firstEntries[yi], 0);
        }
        return corrScore;
    }