python modular of FactorGraphModel