code: public TableFactor buildWithCache() {
      return new TableFactor(vars, CachedSparseTensor.cacheAllPermutations(
          SparseTensorBuilder.copyOf(weightBuilder).build()));
    }
docs: Creates a {@code TableFactor} containing all of the assignment/weight
  mappings that added to {@code this} builder. Caches out all permutations of
  the weight tensor, for fast multiplication and additions. The returned
  factor is defined over the variables in {@code this.getVars()}.
  
  @return