docs: @Override
    public SufficientStatistics train(ParametricFactorGraph bn,
        SufficientStatistics initialParameters, 
        Iterable<Example<DynamicAssignment, DynamicAssignment>> trainingDataExamples) {
  
      List<DynamicAssignment> trainingData = getOutputAssignments(trainingDataExamples, true);
      SufficientStatistics[] previousIterationStatistics = new SufficientStatistics[trainingData.size()];
  
      for (int i = 0; i < numIterations; i++) {
        log.notifyIterationStart(i);
        for (int j = 0; j < trainingData.size(); j++) {
          if (i > 0) {
            // Subtract out old statistics if they exist.
            initialParameters.increment(previousIterationStatistics[j], -1.0);
          }
  
          // Get the current training data point and the most recent factor graph
          // based on the current iteration.
          DynamicAssignment dynamicExample = trainingData.get(j);
          DynamicFactorGraph dynamicFactorGraph = bn.getModelFromParameters(initialParameters);
          FactorGraph currentFactorGraph = dynamicFactorGraph.getFactorGraph(dynamicExample);
          Assignment trainingExample = dynamicFactorGraph.getVariables().toAssignment(dynamicExample);
          log.log(i, j, trainingExample, currentFactorGraph);
  
          // Compute the marginal distribution of currentFactorGraph conditioned on
          // the current training example.
          FactorGraph conditionalFactorGraph = currentFactorGraph.conditional(trainingExample);
          MarginalSet marginals = inferenceEngine.computeMarginals(conditionalFactorGraph);
              
          // Update new sufficient statistics
          SufficientStatistics exampleStatistics = bn.getNewSufficientStatistics(); 
          bn.incrementSufficientStatistics(exampleStatistics, initialParameters, marginals, 1.0);
          previousIterationStatistics[j] = exampleStatistics;
          initialParameters.increment(exampleStatistics, 1.0);
        }
        log.notifyIterationEnd(i);
      }
      
      return initialParameters;
    }