docs: public static <O> ParametricFactorGraph buildFeaturizedSequenceModel(DiscreteVariable inputType, 
        DiscreteVariable labelType, DiscreteVariable featureDictionary, Tensor labelRestrictions,
        boolean noTransitions, boolean locallyNormalized) {
      ObjectVariable inputVectorType = new ObjectVariable(Tensor.class);
  
      // Create a dynamic factor graph with a single plate replicating
      // the input/output variables.
      ParametricFactorGraphBuilder builder = new ParametricFactorGraphBuilder();
      builder.addPlate(TaggerUtils.PLATE_NAME, new VariableNumMap(Ints.asList(1, 2, 4),
          Arrays.asList(TaggerUtils.INPUT_FEATURES_NAME, TaggerUtils.INPUT_NAME, TaggerUtils.OUTPUT_NAME),
          Arrays.<Variable> asList(inputVectorType, inputType, labelType)), 10000);
  
      // Create a classifier from local word contexts to pos tags.
      VariableNumMap classifierVars = new VariableNumMap(Ints.asList(1, 4),
          Arrays.asList(INPUT_FEATURES_PATTERN, OUTPUT_PATTERN), Arrays.<Variable> asList(inputVectorType, labelType));
      VariableNumMap wordVectorVar = classifierVars.getVariablesByName(INPUT_FEATURES_PATTERN);
      VariableNumMap posVar = classifierVars.getVariablesByName(OUTPUT_PATTERN);
      ParametricLinearClassifierFactor wordClassifier = new ParametricLinearClassifierFactor(wordVectorVar, posVar,
          VariableNumMap.EMPTY, featureDictionary, null, false);
  
      // Create a constant factor for encoding label restrictions.
      VariableNumMap restrictionVars = new VariableNumMap(Ints.asList(2, 4),
          Arrays.asList(INPUT_PATTERN, OUTPUT_PATTERN), Arrays.<Variable> asList(inputType, labelType));
      VariableNumMap wordVar = restrictionVars.getVariablesByName(INPUT_PATTERN);
      VariableNumMap labelVar = restrictionVars.getVariablesByName(OUTPUT_PATTERN);
      DiscreteFactor restrictions = new TableFactor(wordVar.union(labelVar), labelRestrictions.relabelDimensions(new int[] {2, 4}));
  
      // Create a factor connecting adjacent labels.
      VariableNumMap adjacentVars = new VariableNumMap(Ints.asList(3, 4),
          Arrays.asList(PREV_OUTPUT_PATTERN, OUTPUT_PATTERN), Arrays.asList(labelType, labelType));
      ParametricFactor adjacentFactor = null;
      if (!noTransitions) {
        adjacentFactor = new DenseIndicatorLogLinearFactor(adjacentVars, false);
      }
  
      if (locallyNormalized) {
        // Add a factor that normalizes the distribution.
        List<ParametricFactor> factors = Lists.<ParametricFactor>newArrayList(
            new ConstantParametricFactor(restrictions.getVars(), restrictions), wordClassifier);
        VariableNumMap inputVars = wordVectorVar.union(wordVar);
        VariableNumMap conditionalVars = VariableNumMap.EMPTY;
        VariableNumMap outputVar = adjacentVars.getVariablesByName(OUTPUT_PATTERN);
        if (adjacentFactor != null) {
          factors.add(adjacentFactor);
          conditionalVars = adjacentVars.getVariablesByName(PREV_OUTPUT_PATTERN);
        }
        VariableNumMap factorVars = VariableNumMap.unionAll(inputVars, conditionalVars, outputVar);
        ParametricNormalizingFactor normalizingFactor = new ParametricNormalizingFactor(
            inputVars, conditionalVars, outputVar, factors);
        builder.addFactor(NORMALIZED_FACTOR, normalizingFactor,
            VariableNumPattern.fromTemplateVariables(factorVars, VariableNumMap.EMPTY, builder.getDynamicVariableSet()));
      } else {
        // Just add each factor to the factor graph 
        builder.addFactor(TaggerUtils.WORD_LABEL_FACTOR, wordClassifier,
            VariableNumPattern.fromTemplateVariables(classifierVars, VariableNumMap.EMPTY, builder.getDynamicVariableSet()));
        builder.addConstantFactor(TaggerUtils.LABEL_RESTRICTION_FACTOR, new ReplicatedFactor(restrictions,
            VariableNumPattern.fromTemplateVariables(restrictionVars, VariableNumMap.EMPTY, builder.getDynamicVariableSet())));
        if (adjacentFactor != null) {
          builder.addFactor(TaggerUtils.TRANSITION_FACTOR, adjacentFactor,
              VariableNumPattern.fromTemplateVariables(adjacentVars, VariableNumMap.EMPTY, builder.getDynamicVariableSet()));
        }
      }
      return builder.build();
    }