<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def is_imap(self, model):
 """ Checks whether the given BayesianModel is Imap of JointProbabilityDistribution Parameters model : An instance of BayesianModel Class, for which you want to check the Imap Returns -------- boolean : True if given bayesian model is Imap for Joint Probability Distribution False otherwise Examples -------- 0.04, 0.04, 0.32, 0.024, 0.024, 0.192, 0.016, 0.016, 0.128] True """

        from pgmpy.models import BayesianModel
        if not isinstance(model, BayesianModel):
            raise TypeError("model must be an instance of BayesianModel")
        factors = [cpd.to_factor() for cpd in model.get_cpds()]
        factor_prod = six.moves.reduce(mul, factors)
        JPD_fact = DiscreteFactor(self.variables, self.cardinality, self.values)
        if JPD_fact == factor_prod:
            return True
        else:
            return False