Program: 131346
Project: 131346
Buggy source:
public FgModel train(FgModel model,FgExampleList data){
  ExampleObjective exObj;
  boolean isMinimize;
  if (prm.trainer == Trainer.ERMA) {
    exObj=new ErmaObjective(data,prm.infFactory,prm.dlFactory);
    isMinimize=true;
  }
 else {
    exObj=new CrfObjective(data,prm.infFactory,prm.useMseForValue);
    isMinimize=false;
  }
  AvgBatchObjective objective=new AvgBatchObjective(exObj,model,prm.numThreads);
  if (prm.optimizer != null) {
    DifferentiableFunction fn=objective;
    if (prm.regularizer != null) {
      prm.regularizer.setNumDimensions(model.getNumParams());
      fn=new DifferentiableFunctionOpts.AddFunctions(objective,prm.regularizer);
    }
    if (isMinimize == true) {
      prm.optimizer.minimize(fn,model.getParams());
    }
 else {
      prm.optimizer.maximize(fn,model.getParams());
    }
    log.info("String_Node_Str" + fn.getValue(model.getParams()));
  }
 else {
    DifferentiableBatchFunction fn=objective;
    if (prm.regularizer != null) {
      prm.regularizer.setNumDimensions(model.getNumParams());
      DifferentiableBatchFunction br=new FunctionAsBatchFunction(prm.regularizer,objective.getNumExamples());
      fn=new BatchFunctionOpts.AddFunctions(objective,br);
    }
    if (isMinimize == true) {
      prm.batchOptimizer.minimize(fn,model.getParams());
    }
 else {
      prm.batchOptimizer.maximize(fn,model.getParams());
    }
    log.info("String_Node_Str" + fn.getValue(model.getParams(),IntSort.getIndexArray(fn.getNumExamples())));
  }
  objective.shutdown();
  return model;
}

Fixed version (ground truth):
public FgModel train(FgModel model,FgExampleList data){
  ExampleObjective exObj;
  boolean isMinimize;
  if (prm.trainer == Trainer.ERMA) {
    exObj=new ErmaObjective(data,prm.infFactory,prm.dlFactory);
    isMinimize=true;
  }
 else {
    exObj=new CrfObjective(data,prm.infFactory,prm.useMseForValue);
    isMinimize=false;
  }
  AvgBatchObjective objective=new AvgBatchObjective(exObj,model,prm.numThreads);
  Regularizer reg=prm.regularizer;
  if (prm.optimizer != null) {
    DifferentiableFunction fn=objective;
    if (reg != null) {
      reg.setNumDimensions(model.getNumParams());
      DifferentiableFunction nbr=isMinimize ? DifferentiableFunctionOpts.negate(reg) : reg;
      fn=new DifferentiableFunctionOpts.AddFunctions(objective,nbr);
    }
    if (isMinimize == true) {
      prm.optimizer.minimize(fn,model.getParams());
    }
 else {
      prm.optimizer.maximize(fn,model.getParams());
    }
    log.info("String_Node_Str" + fn.getValue(model.getParams()));
  }
 else {
    DifferentiableBatchFunction fn=objective;
    if (reg != null) {
      reg.setNumDimensions(model.getNumParams());
      DifferentiableBatchFunction br=new FunctionAsBatchFunction(reg,objective.getNumExamples());
      DifferentiableBatchFunction nbr=isMinimize ? new BatchFunctionOpts.NegateFunction(br) : br;
      fn=new BatchFunctionOpts.AddFunctions(objective,nbr);
    }
    if (isMinimize == true) {
      prm.batchOptimizer.minimize(fn,model.getParams());
    }
 else {
      prm.batchOptimizer.maximize(fn,model.getParams());
    }
    log.info("String_Node_Str" + fn.getValue(model.getParams(),IntSort.getIndexArray(fn.getNumExamples())));
  }
  objective.shutdown();
  return model;
}