docs: private static final Tensor getFactorMessage(int curVarNum, Tensor logFactorWeights,
        List<Tensor> variableMarginals, IndexedList<Integer> variableNums) {
      Tensor factorMessage = logFactorWeights;
      // Each message is the outer product of all variable marginals, except
      // variable i, elementwise multiplied by the log factor weights.
      int[] weightVariableNums = factorMessage.getDimensionNumbers();
      List<Integer> variablesToMarginalize = Lists.newArrayList();
      for (int j = 0; j < weightVariableNums.length; j++) {
        if (weightVariableNums[j] == curVarNum) {
          continue;
        }
  
        Tensor variableMarginal = variableMarginals.get(variableNums.getIndex(weightVariableNums[j]));
        factorMessage = factorMessage.elementwiseProduct(variableMarginal);
        variablesToMarginalize.add(weightVariableNums[j]);
      }
      return factorMessage.sumOutDimensions(variablesToMarginalize);
    }