code: private static VarTensor getProductOfAllFactors(FactorGraph fg, Algebra s) {
          VarTensor joint = new VarTensor(s, new VarSet(), s.one());
          for (int a=0; a<fg.getNumFactors(); a++) {
              Factor f = fg.getFactor(a);
              VarTensor factor = safeNewVarTensor(s, f);
              assert !factor.containsBadValues() : factor;
              joint.prod(factor);
          }
          return joint;
      }
docs: Gets the product of all the factors in the factor graph. If working in
  the log-domain, this will do factor addition.
  
  @return The product of all the factors.