code: private void setTargets(TrellisNode[][] trellis, double[] scaling, int[] label) {
          TrellisNode[] t0 = trellis[0];
  
          // Finding the normalizer for our first 'column' in the matrix
          double normalizer = 0.0;
          for (int i = 0; i < numClasses; i++) {
              normalizer += t0[i].expScores[0] * t0[i].beta;
          }
  
          for (int i = 0; i < numClasses; i++) {
              if (label[0] == i) {
                  t0[i].target[0] = 1 - t0[i].expScores[0] * t0[i].beta / normalizer;
              } else {
                  t0[i].target[0] = -t0[i].expScores[0] * t0[i].beta / normalizer;
              }
          }
  
          for (int t = 1; t < label.length; t++) {
              normalizer = 0.0;
              TrellisNode[] tt = trellis[t];
              TrellisNode[] tt1 = trellis[t-1];
              for (int i = 0; i < numClasses; i++) {
                  normalizer += tt[i].alpha * tt[i].beta;
              }
              normalizer *= scaling[t];
  
              for (int i = 0; i < numClasses; i++) {
                  TrellisNode tti = tt[i];
                  for (int j = 0; j < numClasses; j++) {
                      if (label[t] == i && label[t - 1] == j) {
                          tti.target[j] = 1 - tti.expScores[j] * tt1[j].alpha * tti.beta / normalizer;
                      } else {
                          tti.target[j] = -tti.expScores[j] * tt1[j].alpha * tti.beta / normalizer;
                      }
                  }
              }
          }
      }
docs: Set training targets based on results of forward-backward