code: private void normalizeArcWork(final DetArcWork arcWork) {
      Collections.sort(arcWork.pendingElements);
      ArrayList<DetElement> deduped = Lists.newArrayList();
      for (int i = 0; i < arcWork.pendingElements.size(); i++) {
        // first update the running common divisor that we'll use later
        DetElement currentElement = arcWork.pendingElements.get(i);
        arcWork.computedDivisor = unionSemiring.commonDivisor(arcWork.computedDivisor, currentElement.residual);
        // now we want to add and dedup at the same time (this is ok because we sorted)
        if (deduped.isEmpty() || deduped.get(deduped.size() - 1).inputStateId != currentElement.inputStateId) {
          deduped.add(currentElement);
        } else {
          // merge this next one into the existing one
          int lastIndex = deduped.size() - 1;
          DetElement lastElement = deduped.get(lastIndex);
          UnionWeight<GallicWeight> merged = unionSemiring.plus(lastElement.residual, currentElement.residual);
          deduped.set(lastIndex, lastElement.withResidual(merged));
        }
      }
      arcWork.pendingElements = deduped;
  
      // dividing out the weights with the divisor across all elements
      for (int i = 0; i < arcWork.pendingElements.size(); i++) {
        DetElement currentElement = arcWork.pendingElements.get(i);
        UnionWeight<GallicWeight> divided = unionSemiring.divide(currentElement.residual, arcWork.computedDivisor);
        arcWork.pendingElements.set(i, currentElement.withResidual(divided));
        // we aren't quantizing anything in jopenfst but we would want to quantize here if we add that in the future
      }
    }
docs: and compute new resulting arc weights