def __call__(self, model, guide, *args, **kwargs): if self.options.get("optimize", None): with funsor.interpreter.interpretation(funsor.optimizer.optimize): elbo_expr = elbo(model, guide, *args, **kwargs) return funsor.reinterpret(elbo_expr) return elbo(model, guide, *args, **kwargs)
def test_reinterpret(expr): x = eval(expr) assert funsor.reinterpret(x) is x