def _validate_slope_ar1_prior(slope_ar1_prior, sdy):
     if slope_ar1_prior is None:
         slope_ar1_prior = R.Ar1CoefficientPrior()
     if not isinstance(slope_ar1_prior, R.Ar1CoefficientPrior):
         raise Exception("Wrong type passed for slope_ar1_prior.  "
                         "Expected an R.Ar1CoefficientPrior")
     return slope_ar1_prior
    def __setstate__(self, payload):
        self.level_sigma_prior = R.SdPrior(1, 1)
        self.slope_sigma_prior = R.SdPrior(1, 1)
        self.slope_ar1_prior = R.Ar1CoefficientPrior()
        self.slope_mean_prior = R.NormalPrior(0, 1)
        self.level_sigma_prior.__setstate__(payload["level_sigma_prior"])
        self.slope_sigma_prior.__setstate__(payload["slope_sigma_prior"])
        self.slope_ar1_prior.__setstate__(payload["slope_ar1_prior"])
        self.slope_mean_prior.__setstate__(payload["slope_mean_prior"])
        self._create_model()

        initial_state_mean = payload["initial_state_mean"]
        initial_state_variance = payload["initial_state_variance"]
        self._set_initial_state_distribution(
            initial_level_prior=R.NormalPrior(
                initial_state_mean[0], np.sqrt(initial_state_variance[0, 0])),
            initial_slope_prior=R.NormalPrior(
                initial_state_mean[0], np.sqrt(initial_state_variance[0, 0]))
        )

        self.level_sigma = payload.get("level_sigma", None)
        self.slope_sigma = payload.get("slope_sigma", None)
        self.slope_ar1 = payload.get("slope_ar1", None)
        self.slope_mean = payload.get("slope_mean", None)
        self._state_contribution = payload.get("state_contribution", None)