class UpdateLambdaAndAlpha extends ComputeFunction {

    @Override
    public void calc(ComContext context) {
        int iterNum = context.getStepNo();
        Tuple2<Long, Integer> tuple2 = ((List<Tuple2<Long, Integer>>) context.getObj(LdaVariable.shape)).get(0);
        int vocabularySize = tuple2.f1;
        DenseMatrix lambda;
        DenseMatrix alpha;
        if (context.getStepNo() == 1) {
            Tuple2<DenseMatrix, DenseMatrix> initGammaAndAlpha =
                    ((List<Tuple2<DenseMatrix, DenseMatrix>>) context.getObj(LdaVariable.initModel)).get(0);
            lambda = initGammaAndAlpha.f0;
            alpha = initGammaAndAlpha.f1;
        } else {
            lambda = context.getObj(LdaVariable.lambda);
            alpha = context.getObj(LdaVariable.alpha);
        }
        DenseMatrix wordTopicStat = new DenseMatrix(numTopic, vocabularySize, context.getObj(LdaVariable.wordTopicStat));
        DenseMatrix logPhat = new DenseMatrix(numTopic, 1, context.getObj(LdaVariable.logPhatPart));
        long nonEmptyDocsN = Math.round(((double[]) context.getObj(LdaVariable.nonEmptyDocCount))[0]);
        Tuple2<DenseMatrix, DenseMatrix> out = calculateLambdaAndAlpha(lambda, alpha, wordTopicStat, logPhat,
                nonEmptyDocsN, iterNum, tau0, kappa, eta, subSampleRatio,
                numTopic, optimizeDocConcentration);
        context.putObj(LdaVariable.lambda, out.f0);
        context.putObj(LdaVariable.alpha, out.f1);
    }

    public  UpdateLambdaAndAlpha(int numTopic, double learningOffset, double learningRate,
                                double subSampleRatio, boolean optimizeDocConcentration, double eta);

}