#ifndef MODELS_HPP
#define MODELS_HPP
#define STAN__SERVICES__COMMAND_HPP
#include <rstan/rstaninc.hpp>
#ifndef USE_STANC3
#define USE_STANC3
#endif
// Code generated by stanc v2.32.2
#include <stan/model/model_header.hpp>
namespace modela5f78e2459e__namespace {
using stan::model::model_base_crtp;
using namespace stan::math;
stan::math::profile_map profiles__;
static constexpr std::array<const char*, 91> locations_array__ =
  {" (found before start of program)",
  " (in 'anon_model', line 32, column 2 to column 19)",
  " (in 'anon_model', line 33, column 2 to column 31)",
  " (in 'anon_model', line 34, column 2 to column 26)",
  " (in 'anon_model', line 53, column 4 to column 21)",
  " (in 'anon_model', line 54, column 4 to column 24)",
  " (in 'anon_model', line 55, column 4 to column 20)",
  " (in 'anon_model', line 56, column 4 to column 24)",
  " (in 'anon_model', line 58, column 4 to column 33)",
  " (in 'anon_model', line 59, column 4 to column 38)",
  " (in 'anon_model', line 60, column 4 to column 34)",
  " (in 'anon_model', line 62, column 4 to column 30)",
  " (in 'anon_model', line 65, column 6 to column 77)",
  " (in 'anon_model', line 64, column 19 to line 66, column 5)",
  " (in 'anon_model', line 64, column 4 to line 66, column 5)",
  " (in 'anon_model', line 69, column 29 to column 30)",
  " (in 'anon_model', line 69, column 15 to column 16)",
  " (in 'anon_model', line 69, column 8 to column 32)",
  " (in 'anon_model', line 72, column 12 to column 55)",
  " (in 'anon_model', line 73, column 12 to column 71)",
  " (in 'anon_model', line 71, column 23 to line 74, column 9)",
  " (in 'anon_model', line 71, column 8 to line 74, column 9)",
  " (in 'anon_model', line 77, column 16 to column 73)",
  " (in 'anon_model', line 76, column 27 to line 78, column 13)",
  " (in 'anon_model', line 76, column 12 to line 78, column 13)",
  " (in 'anon_model', line 75, column 23 to line 79, column 9)",
  " (in 'anon_model', line 75, column 8 to line 79, column 9)",
  " (in 'anon_model', line 81, column 26 to column 27)",
  " (in 'anon_model', line 81, column 15 to column 16)",
  " (in 'anon_model', line 81, column 8 to column 29)",
  " (in 'anon_model', line 83, column 12 to column 43)",
  " (in 'anon_model', line 84, column 12 to column 57)",
  " (in 'anon_model', line 82, column 22 to line 85, column 9)",
  " (in 'anon_model', line 82, column 8 to line 85, column 9)",
  " (in 'anon_model', line 68, column 4 to line 86, column 5)",
  " (in 'anon_model', line 89, column 8 to column 57)",
  " (in 'anon_model', line 88, column 19 to line 90, column 5)",
  " (in 'anon_model', line 88, column 4 to line 90, column 5)",
  " (in 'anon_model', line 93, column 8 to column 79)",
  " (in 'anon_model', line 94, column 8 to column 90)",
  " (in 'anon_model', line 96, column 8 to column 87)",
  " (in 'anon_model', line 92, column 20 to line 97, column 5)",
  " (in 'anon_model', line 92, column 4 to line 97, column 5)",
  " (in 'anon_model', line 37, column 2 to column 48)",
  " (in 'anon_model', line 38, column 2 to column 33)",
  " (in 'anon_model', line 40, column 4 to column 32)",
  " (in 'anon_model', line 39, column 17 to line 41, column 3)",
  " (in 'anon_model', line 39, column 2 to line 41, column 3)",
  " (in 'anon_model', line 43, column 11 to column 12)",
  " (in 'anon_model', line 43, column 4 to column 24)",
  " (in 'anon_model', line 45, column 6 to column 40)",
  " (in 'anon_model', line 44, column 19 to line 46, column 5)",
  " (in 'anon_model', line 44, column 4 to line 46, column 5)",
  " (in 'anon_model', line 47, column 4 to column 35)",
  " (in 'anon_model', line 42, column 2 to line 48, column 3)",
  " (in 'anon_model', line 13, column 2 to column 17)",
  " (in 'anon_model', line 14, column 2 to column 17)",
  " (in 'anon_model', line 15, column 2 to column 17)",
  " (in 'anon_model', line 16, column 8 to column 9)",
  " (in 'anon_model', line 16, column 2 to column 35)",
  " (in 'anon_model', line 17, column 8 to column 9)",
  " (in 'anon_model', line 17, column 2 to column 36)",
  " (in 'anon_model', line 18, column 8 to column 9)",
  " (in 'anon_model', line 18, column 22 to column 23)",
  " (in 'anon_model', line 18, column 2 to column 27)",
  " (in 'anon_model', line 19, column 2 to column 15)",
  " (in 'anon_model', line 20, column 2 to column 25)",
  " (in 'anon_model', line 21, column 2 to column 22)",
  " (in 'anon_model', line 22, column 2 to column 28)",
  " (in 'anon_model', line 24, column 2 to column 18)",
  " (in 'anon_model', line 25, column 8 to column 10)",
  " (in 'anon_model', line 25, column 2 to column 38)",
  " (in 'anon_model', line 26, column 8 to column 10)",
  " (in 'anon_model', line 26, column 23 to column 24)",
  " (in 'anon_model', line 26, column 2 to column 46)",
  " (in 'anon_model', line 27, column 8 to column 10)",
  " (in 'anon_model', line 27, column 23 to column 24)",
  " (in 'anon_model', line 27, column 2 to column 40)",
  " (in 'anon_model', line 29, column 2 to column 30)",
  " (in 'anon_model', line 32, column 8 to column 9)",
  " (in 'anon_model', line 33, column 8 to column 9)",
  " (in 'anon_model', line 34, column 8 to column 9)",
  " (in 'anon_model', line 34, column 18 to column 19)",
  " (in 'anon_model', line 53, column 18 to column 19)",
  " (in 'anon_model', line 54, column 21 to column 22)",
  " (in 'anon_model', line 55, column 17 to column 18)",
  " (in 'anon_model', line 56, column 21 to column 22)",
  " (in 'anon_model', line 58, column 29 to column 31)",
  " (in 'anon_model', line 59, column 34 to column 36)",
  " (in 'anon_model', line 60, column 30 to column 32)",
  " (in 'anon_model', line 62, column 10 to column 11)"};
class modela5f78e2459e_ final : public model_base_crtp<modela5f78e2459e_> {
private:
  int D;
  int N;
  int L;
  std::vector<int> y;
  std::vector<int> ll;
  std::vector<Eigen::Matrix<double,1,-1>> x;
  double mu_mean;
  double mu_stdev;
  double sigma_location;
  double sigma_scale;
  int Nx;
  std::vector<int> llx;
  std::vector<Eigen::Matrix<double,1,-1>> counterfact_x_tilde;
  std::vector<Eigen::Matrix<double,1,-1>> counterfact_x;
  std::vector<int> status_indexes;
public:
  ~modela5f78e2459e_() {}
  modela5f78e2459e_(stan::io::var_context& context__, unsigned int
                    random_seed__ = 0, std::ostream* pstream__ = nullptr)
      : model_base_crtp(0) {
    int current_statement__ = 0;
    using local_scalar_t__ = double;
    boost::ecuyer1988 base_rng__ =
      stan::services::util::create_rng(random_seed__, 0);
    // suppress unused var warning
    (void) base_rng__;
    static constexpr const char* function__ =
      "modela5f78e2459e__namespace::modela5f78e2459e_";
    // suppress unused var warning
    (void) function__;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      current_statement__ = 55;
      context__.validate_dims("data initialization", "D", "int",
        std::vector<size_t>{});
      D = std::numeric_limits<int>::min();
      current_statement__ = 55;
      D = context__.vals_i("D")[(1 - 1)];
      current_statement__ = 55;
      stan::math::check_greater_or_equal(function__, "D", D, 1);
      current_statement__ = 56;
      context__.validate_dims("data initialization", "N", "int",
        std::vector<size_t>{});
      N = std::numeric_limits<int>::min();
      current_statement__ = 56;
      N = context__.vals_i("N")[(1 - 1)];
      current_statement__ = 56;
      stan::math::check_greater_or_equal(function__, "N", N, 1);
      current_statement__ = 57;
      context__.validate_dims("data initialization", "L", "int",
        std::vector<size_t>{});
      L = std::numeric_limits<int>::min();
      current_statement__ = 57;
      L = context__.vals_i("L")[(1 - 1)];
      current_statement__ = 57;
      stan::math::check_greater_or_equal(function__, "L", L, 1);
      current_statement__ = 58;
      stan::math::validate_non_negative_index("y", "N", N);
      current_statement__ = 59;
      context__.validate_dims("data initialization", "y", "int",
        std::vector<size_t>{static_cast<size_t>(N)});
      y = std::vector<int>(N, std::numeric_limits<int>::min());
      current_statement__ = 59;
      y = context__.vals_i("y");
      current_statement__ = 59;
      stan::math::check_greater_or_equal(function__, "y", y, 0);
      current_statement__ = 59;
      stan::math::check_less_or_equal(function__, "y", y, 1);
      current_statement__ = 60;
      stan::math::validate_non_negative_index("ll", "N", N);
      current_statement__ = 61;
      context__.validate_dims("data initialization", "ll", "int",
        std::vector<size_t>{static_cast<size_t>(N)});
      ll = std::vector<int>(N, std::numeric_limits<int>::min());
      current_statement__ = 61;
      ll = context__.vals_i("ll");
      current_statement__ = 61;
      stan::math::check_greater_or_equal(function__, "ll", ll, 1);
      current_statement__ = 61;
      stan::math::check_less_or_equal(function__, "ll", ll, L);
      current_statement__ = 62;
      stan::math::validate_non_negative_index("x", "N", N);
      current_statement__ = 63;
      stan::math::validate_non_negative_index("x", "D", D);
      current_statement__ = 64;
      context__.validate_dims("data initialization", "x", "double",
        std::vector<size_t>{static_cast<size_t>(N), static_cast<size_t>(D)});
      x = std::vector<Eigen::Matrix<double,1,-1>>(N,
            Eigen::Matrix<double,1,-1>::Constant(D,
              std::numeric_limits<double>::quiet_NaN()));
      {
        std::vector<local_scalar_t__> x_flat__;
        current_statement__ = 64;
        x_flat__ = context__.vals_r("x");
        current_statement__ = 64;
        pos__ = 1;
        current_statement__ = 64;
        for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
          current_statement__ = 64;
          for (int sym2__ = 1; sym2__ <= N; ++sym2__) {
            current_statement__ = 64;
            stan::model::assign(x, x_flat__[(pos__ - 1)],
              "assigning variable x", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 64;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 65;
      context__.validate_dims("data initialization", "mu_mean", "double",
        std::vector<size_t>{});
      mu_mean = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 65;
      mu_mean = context__.vals_r("mu_mean")[(1 - 1)];
      current_statement__ = 66;
      context__.validate_dims("data initialization", "mu_stdev", "double",
        std::vector<size_t>{});
      mu_stdev = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 66;
      mu_stdev = context__.vals_r("mu_stdev")[(1 - 1)];
      current_statement__ = 66;
      stan::math::check_greater_or_equal(function__, "mu_stdev", mu_stdev, 0);
      current_statement__ = 67;
      context__.validate_dims("data initialization", "sigma_location",
        "double", std::vector<size_t>{});
      sigma_location = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 67;
      sigma_location = context__.vals_r("sigma_location")[(1 - 1)];
      current_statement__ = 68;
      context__.validate_dims("data initialization", "sigma_scale", "double",
        std::vector<size_t>{});
      sigma_scale = std::numeric_limits<double>::quiet_NaN();
      current_statement__ = 68;
      sigma_scale = context__.vals_r("sigma_scale")[(1 - 1)];
      current_statement__ = 68;
      stan::math::check_greater_or_equal(function__, "sigma_scale",
        sigma_scale, 0);
      current_statement__ = 69;
      context__.validate_dims("data initialization", "Nx", "int",
        std::vector<size_t>{});
      Nx = std::numeric_limits<int>::min();
      current_statement__ = 69;
      Nx = context__.vals_i("Nx")[(1 - 1)];
      current_statement__ = 69;
      stan::math::check_greater_or_equal(function__, "Nx", Nx, 0);
      current_statement__ = 70;
      stan::math::validate_non_negative_index("llx", "Nx", Nx);
      current_statement__ = 71;
      context__.validate_dims("data initialization", "llx", "int",
        std::vector<size_t>{static_cast<size_t>(Nx)});
      llx = std::vector<int>(Nx, std::numeric_limits<int>::min());
      current_statement__ = 71;
      llx = context__.vals_i("llx");
      current_statement__ = 71;
      stan::math::check_greater_or_equal(function__, "llx", llx, 1);
      current_statement__ = 71;
      stan::math::check_less_or_equal(function__, "llx", llx, L);
      current_statement__ = 72;
      stan::math::validate_non_negative_index("counterfact_x_tilde", "Nx", Nx);
      current_statement__ = 73;
      stan::math::validate_non_negative_index("counterfact_x_tilde", "D", D);
      current_statement__ = 74;
      context__.validate_dims("data initialization", "counterfact_x_tilde",
        "double",
        std::vector<size_t>{static_cast<size_t>(Nx), static_cast<size_t>(D)});
      counterfact_x_tilde = std::vector<Eigen::Matrix<double,1,-1>>(Nx,
                              Eigen::Matrix<double,1,-1>::Constant(D,
                                std::numeric_limits<double>::quiet_NaN()));
      {
        std::vector<local_scalar_t__> counterfact_x_tilde_flat__;
        current_statement__ = 74;
        counterfact_x_tilde_flat__ = context__.vals_r("counterfact_x_tilde");
        current_statement__ = 74;
        pos__ = 1;
        current_statement__ = 74;
        for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
          current_statement__ = 74;
          for (int sym2__ = 1; sym2__ <= Nx; ++sym2__) {
            current_statement__ = 74;
            stan::model::assign(counterfact_x_tilde,
              counterfact_x_tilde_flat__[(pos__ - 1)],
              "assigning variable counterfact_x_tilde",
              stan::model::index_uni(sym2__), stan::model::index_uni(sym1__));
            current_statement__ = 74;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 75;
      stan::math::validate_non_negative_index("counterfact_x", "Nx", Nx);
      current_statement__ = 76;
      stan::math::validate_non_negative_index("counterfact_x", "D", D);
      current_statement__ = 77;
      context__.validate_dims("data initialization", "counterfact_x",
        "double",
        std::vector<size_t>{static_cast<size_t>(Nx), static_cast<size_t>(D)});
      counterfact_x = std::vector<Eigen::Matrix<double,1,-1>>(Nx,
                        Eigen::Matrix<double,1,-1>::Constant(D,
                          std::numeric_limits<double>::quiet_NaN()));
      {
        std::vector<local_scalar_t__> counterfact_x_flat__;
        current_statement__ = 77;
        counterfact_x_flat__ = context__.vals_r("counterfact_x");
        current_statement__ = 77;
        pos__ = 1;
        current_statement__ = 77;
        for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
          current_statement__ = 77;
          for (int sym2__ = 1; sym2__ <= Nx; ++sym2__) {
            current_statement__ = 77;
            stan::model::assign(counterfact_x, counterfact_x_flat__[(pos__ -
              1)], "assigning variable counterfact_x",
              stan::model::index_uni(sym2__), stan::model::index_uni(sym1__));
            current_statement__ = 77;
            pos__ = (pos__ + 1);
          }
        }
      }
      current_statement__ = 78;
      context__.validate_dims("data initialization", "status_indexes", "int",
        std::vector<size_t>{static_cast<size_t>(2)});
      status_indexes = std::vector<int>(2, std::numeric_limits<int>::min());
      current_statement__ = 78;
      status_indexes = context__.vals_i("status_indexes");
      current_statement__ = 79;
      stan::math::validate_non_negative_index("mu", "D", D);
      current_statement__ = 80;
      stan::math::validate_non_negative_index("sigma", "D", D);
      current_statement__ = 81;
      stan::math::validate_non_negative_index("beta", "L", L);
      current_statement__ = 82;
      stan::math::validate_non_negative_index("beta", "D", D);
      current_statement__ = 83;
      stan::math::validate_non_negative_index("mu_prior", "D", D);
      current_statement__ = 84;
      stan::math::validate_non_negative_index("sigma_prior", "D", D);
      current_statement__ = 85;
      stan::math::validate_non_negative_index("p_prior", "N", N);
      current_statement__ = 86;
      stan::math::validate_non_negative_index("p_predicted", "N", N);
      current_statement__ = 87;
      stan::math::validate_non_negative_index("p_predicted_default", "Nx", Nx);
      current_statement__ = 88;
      stan::math::validate_non_negative_index("p_predicted_intervention",
        "Nx", Nx);
      current_statement__ = 89;
      stan::math::validate_non_negative_index("predicted_difference", "Nx",
        Nx);
      current_statement__ = 90;
      stan::math::validate_non_negative_index("status_diff", "L", L);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
    num_params_r__ = D + D + (L * D);
  }
  inline std::string model_name() const final {
    return "modela5f78e2459e_";
  }
  inline std::vector<std::string> model_compile_info() const noexcept {
    return std::vector<std::string>{"stanc_version = stanc3 v2.32.2",
             "stancflags = --"};
  }
  template <bool propto__, bool jacobian__, typename VecR, typename VecI,
            stan::require_vector_like_t<VecR>* = nullptr,
            stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>
  inline stan::scalar_type_t<VecR>
  log_prob_impl(VecR& params_r__, VecI& params_i__, std::ostream*
                pstream__ = nullptr) const {
    using T__ = stan::scalar_type_t<VecR>;
    using local_scalar_t__ = T__;
    T__ lp__(0.0);
    stan::math::accumulator<T__> lp_accum__;
    stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    static constexpr const char* function__ =
      "modela5f78e2459e__namespace::log_prob";
    // suppress unused var warning
    (void) function__;
    try {
      std::vector<local_scalar_t__> mu =
        std::vector<local_scalar_t__>(D, DUMMY_VAR__);
      current_statement__ = 1;
      mu = in__.template read<std::vector<local_scalar_t__>>(D);
      std::vector<local_scalar_t__> sigma =
        std::vector<local_scalar_t__>(D, DUMMY_VAR__);
      current_statement__ = 2;
      sigma = in__.template read_constrain_lb<std::vector<local_scalar_t__>,
                jacobian__>(0, lp__, D);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> beta =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(L,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(D, DUMMY_VAR__));
      current_statement__ = 3;
      beta = in__.template read<
               std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>>(L, D);
      {
        current_statement__ = 43;
        lp_accum__.add(stan::math::lognormal_lpdf<propto__>(sigma,
                         sigma_location, sigma_scale));
        current_statement__ = 44;
        lp_accum__.add(stan::math::normal_lpdf<propto__>(mu, mu_mean,
                         mu_stdev));
        current_statement__ = 47;
        for (int l = 1; l <= L; ++l) {
          current_statement__ = 45;
          lp_accum__.add(stan::math::normal_lpdf<propto__>(
                           stan::model::rvalue(beta, "beta",
                             stan::model::index_uni(l)), mu, sigma));
        }
        {
          current_statement__ = 48;
          stan::math::validate_non_negative_index("x_beta_ll", "N", N);
          Eigen::Matrix<local_scalar_t__,-1,1> x_beta_ll =
            Eigen::Matrix<local_scalar_t__,-1,1>::Constant(N, DUMMY_VAR__);
          current_statement__ = 52;
          for (int n = 1; n <= N; ++n) {
            current_statement__ = 50;
            stan::model::assign(x_beta_ll,
              stan::math::multiply(
                stan::model::rvalue(x, "x", stan::model::index_uni(n)),
                stan::model::rvalue(beta, "beta",
                  stan::model::index_uni(
                    stan::model::rvalue(ll, "ll", stan::model::index_uni(n))))),
              "assigning variable x_beta_ll", stan::model::index_uni(n));
          }
          current_statement__ = 53;
          lp_accum__.add(stan::math::bernoulli_logit_lpmf<propto__>(y,
                           x_beta_ll));
        }
      }
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
    lp_accum__.add(lp__);
    return lp_accum__.sum();
  }
  template <typename RNG, typename VecR, typename VecI, typename VecVar,
            stan::require_vector_like_vt<std::is_floating_point,
            VecR>* = nullptr, stan::require_vector_like_vt<std::is_integral,
            VecI>* = nullptr, stan::require_vector_vt<std::is_floating_point,
            VecVar>* = nullptr>
  inline void
  write_array_impl(RNG& base_rng__, VecR& params_r__, VecI& params_i__,
                   VecVar& vars__, const bool
                   emit_transformed_parameters__ = true, const bool
                   emit_generated_quantities__ = true, std::ostream*
                   pstream__ = nullptr) const {
    using local_scalar_t__ = double;
    stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);
    stan::io::serializer<local_scalar_t__> out__(vars__);
    static constexpr bool propto__ = true;
    // suppress unused var warning
    (void) propto__;
    double lp__ = 0.0;
    // suppress unused var warning
    (void) lp__;
    int current_statement__ = 0;
    stan::math::accumulator<double> lp_accum__;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    constexpr bool jacobian__ = false;
    static constexpr const char* function__ =
      "modela5f78e2459e__namespace::write_array";
    // suppress unused var warning
    (void) function__;
    try {
      std::vector<double> mu =
        std::vector<double>(D, std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 1;
      mu = in__.template read<std::vector<local_scalar_t__>>(D);
      std::vector<double> sigma =
        std::vector<double>(D, std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 2;
      sigma = in__.template read_constrain_lb<std::vector<local_scalar_t__>,
                jacobian__>(0, lp__, D);
      std::vector<Eigen::Matrix<double,-1,1>> beta =
        std::vector<Eigen::Matrix<double,-1,1>>(L,
          Eigen::Matrix<double,-1,1>::Constant(D,
            std::numeric_limits<double>::quiet_NaN()));
      current_statement__ = 3;
      beta = in__.template read<
               std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>>(L, D);
      out__.write(mu);
      out__.write(sigma);
      for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
        for (int sym2__ = 1; sym2__ <= L; ++sym2__) {
          out__.write(beta[(sym2__ - 1)][(sym1__ - 1)]);
        }
      }
      if (stan::math::logical_negation(
            (stan::math::primitive_value(emit_transformed_parameters__) ||
            stan::math::primitive_value(emit_generated_quantities__)))) {
        return ;
      }
      if (stan::math::logical_negation(emit_generated_quantities__)) {
        return ;
      }
      std::vector<double> mu_prior =
        std::vector<double>(D, std::numeric_limits<double>::quiet_NaN());
      std::vector<double> sigma_prior =
        std::vector<double>(D, std::numeric_limits<double>::quiet_NaN());
      std::vector<double> p_prior =
        std::vector<double>(N, std::numeric_limits<double>::quiet_NaN());
      std::vector<double> p_predicted =
        std::vector<double>(N, std::numeric_limits<double>::quiet_NaN());
      std::vector<double> p_predicted_default =
        std::vector<double>(Nx, std::numeric_limits<double>::quiet_NaN());
      std::vector<double> p_predicted_intervention =
        std::vector<double>(Nx, std::numeric_limits<double>::quiet_NaN());
      std::vector<double> predicted_difference =
        std::vector<double>(Nx, std::numeric_limits<double>::quiet_NaN());
      std::vector<double> status_diff =
        std::vector<double>(L, std::numeric_limits<double>::quiet_NaN());
      current_statement__ = 14;
      for (int l = 1; l <= L; ++l) {
        current_statement__ = 12;
        stan::model::assign(status_diff,
          (stan::model::rvalue(beta, "beta", stan::model::index_uni(l),
             stan::model::index_uni(
               stan::model::rvalue(status_indexes, "status_indexes",
                 stan::model::index_uni(1)))) -
          stan::model::rvalue(beta, "beta", stan::model::index_uni(l),
            stan::model::index_uni(
              stan::model::rvalue(status_indexes, "status_indexes",
                stan::model::index_uni(2))))),
          "assigning variable status_diff", stan::model::index_uni(l));
      }
      {
        current_statement__ = 15;
        stan::math::validate_non_negative_index("beta_prior", "L", L);
        current_statement__ = 16;
        stan::math::validate_non_negative_index("beta_prior", "D", D);
        std::vector<Eigen::Matrix<double,-1,1>> beta_prior =
          std::vector<Eigen::Matrix<double,-1,1>>(L,
            Eigen::Matrix<double,-1,1>::Constant(D,
              std::numeric_limits<double>::quiet_NaN()));
        current_statement__ = 21;
        for (int d = 1; d <= D; ++d) {
          current_statement__ = 18;
          stan::model::assign(mu_prior,
            stan::math::normal_rng(mu_mean, mu_stdev, base_rng__),
            "assigning variable mu_prior", stan::model::index_uni(d));
          current_statement__ = 19;
          stan::model::assign(sigma_prior,
            stan::math::lognormal_rng(sigma_location, sigma_scale, base_rng__),
            "assigning variable sigma_prior", stan::model::index_uni(d));
        }
        current_statement__ = 26;
        for (int l = 1; l <= L; ++l) {
          current_statement__ = 24;
          for (int d = 1; d <= D; ++d) {
            current_statement__ = 22;
            stan::model::assign(beta_prior,
              stan::math::normal_rng(
                stan::model::rvalue(mu_prior, "mu_prior",
                  stan::model::index_uni(d)),
                stan::model::rvalue(sigma_prior, "sigma_prior",
                  stan::model::index_uni(d)), base_rng__),
              "assigning variable beta_prior", stan::model::index_uni(l),
              stan::model::index_uni(d));
          }
        }
        current_statement__ = 27;
        stan::math::validate_non_negative_index("b_prior", "N", N);
        current_statement__ = 28;
        stan::math::validate_non_negative_index("b_prior", "D", D);
        std::vector<Eigen::Matrix<double,-1,1>> b_prior =
          std::vector<Eigen::Matrix<double,-1,1>>(N,
            Eigen::Matrix<double,-1,1>::Constant(D,
              std::numeric_limits<double>::quiet_NaN()));
        current_statement__ = 33;
        for (int n = 1; n <= N; ++n) {
          current_statement__ = 30;
          stan::model::assign(b_prior,
            stan::model::rvalue(beta_prior, "beta_prior",
              stan::model::index_uni(
                stan::model::rvalue(ll, "ll", stan::model::index_uni(n)))),
            "assigning variable b_prior", stan::model::index_uni(n));
          current_statement__ = 31;
          stan::model::assign(p_prior,
            stan::math::inv_logit(
              stan::math::multiply(
                stan::model::rvalue(x, "x", stan::model::index_uni(n)),
                stan::model::rvalue(b_prior, "b_prior",
                  stan::model::index_uni(n)))), "assigning variable p_prior",
            stan::model::index_uni(n));
        }
      }
      current_statement__ = 37;
      for (int n = 1; n <= N; ++n) {
        current_statement__ = 35;
        stan::model::assign(p_predicted,
          stan::math::inv_logit(
            stan::math::multiply(
              stan::model::rvalue(x, "x", stan::model::index_uni(n)),
              stan::model::rvalue(beta, "beta",
                stan::model::index_uni(
                  stan::model::rvalue(ll, "ll", stan::model::index_uni(n)))))),
          "assigning variable p_predicted", stan::model::index_uni(n));
      }
      current_statement__ = 42;
      for (int n = 1; n <= Nx; ++n) {
        current_statement__ = 38;
        stan::model::assign(p_predicted_default,
          stan::math::inv_logit(
            stan::math::multiply(
              stan::model::rvalue(counterfact_x, "counterfact_x",
                stan::model::index_uni(n)),
              stan::model::rvalue(beta, "beta",
                stan::model::index_uni(
                  stan::model::rvalue(llx, "llx", stan::model::index_uni(n)))))),
          "assigning variable p_predicted_default", stan::model::index_uni(n));
        current_statement__ = 39;
        stan::model::assign(p_predicted_intervention,
          stan::math::inv_logit(
            stan::math::multiply(
              stan::model::rvalue(counterfact_x_tilde, "counterfact_x_tilde",
                stan::model::index_uni(n)),
              stan::model::rvalue(beta, "beta",
                stan::model::index_uni(
                  stan::model::rvalue(llx, "llx", stan::model::index_uni(n)))))),
          "assigning variable p_predicted_intervention",
          stan::model::index_uni(n));
        current_statement__ = 40;
        stan::model::assign(predicted_difference,
          (stan::model::rvalue(p_predicted_intervention,
             "p_predicted_intervention", stan::model::index_uni(n)) -
          stan::model::rvalue(p_predicted_default, "p_predicted_default",
            stan::model::index_uni(n))),
          "assigning variable predicted_difference",
          stan::model::index_uni(n));
      }
      out__.write(mu_prior);
      out__.write(sigma_prior);
      out__.write(p_prior);
      out__.write(p_predicted);
      out__.write(p_predicted_default);
      out__.write(p_predicted_intervention);
      out__.write(predicted_difference);
      out__.write(status_diff);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  template <typename VecVar, typename VecI,
            stan::require_vector_t<VecVar>* = nullptr,
            stan::require_vector_like_vt<std::is_integral, VecI>* = nullptr>
  inline void
  unconstrain_array_impl(const VecVar& params_r__, const VecI& params_i__,
                         VecVar& vars__, std::ostream* pstream__ = nullptr) const {
    using local_scalar_t__ = double;
    stan::io::deserializer<local_scalar_t__> in__(params_r__, params_i__);
    stan::io::serializer<local_scalar_t__> out__(vars__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      std::vector<local_scalar_t__> mu =
        std::vector<local_scalar_t__>(D, DUMMY_VAR__);
      current_statement__ = 1;
      stan::model::assign(mu, in__.read<std::vector<local_scalar_t__>>(D),
        "assigning variable mu");
      out__.write(mu);
      std::vector<local_scalar_t__> sigma =
        std::vector<local_scalar_t__>(D, DUMMY_VAR__);
      current_statement__ = 2;
      stan::model::assign(sigma, in__.read<std::vector<local_scalar_t__>>(D),
        "assigning variable sigma");
      out__.write_free_lb(0, sigma);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> beta =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(L,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(D, DUMMY_VAR__));
      current_statement__ = 3;
      for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
        current_statement__ = 3;
        for (int sym2__ = 1; sym2__ <= L; ++sym2__) {
          current_statement__ = 3;
          stan::model::assign(beta, in__.read<local_scalar_t__>(),
            "assigning variable beta", stan::model::index_uni(sym2__),
            stan::model::index_uni(sym1__));
        }
      }
      out__.write(beta);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  template <typename VecVar, stan::require_vector_t<VecVar>* = nullptr>
  inline void
  transform_inits_impl(const stan::io::var_context& context__, VecVar&
                       vars__, std::ostream* pstream__ = nullptr) const {
    using local_scalar_t__ = double;
    stan::io::serializer<local_scalar_t__> out__(vars__);
    int current_statement__ = 0;
    local_scalar_t__ DUMMY_VAR__(std::numeric_limits<double>::quiet_NaN());
    // suppress unused var warning
    (void) DUMMY_VAR__;
    try {
      current_statement__ = 1;
      context__.validate_dims("parameter initialization", "mu", "double",
        std::vector<size_t>{static_cast<size_t>(D)});
      current_statement__ = 2;
      context__.validate_dims("parameter initialization", "sigma", "double",
        std::vector<size_t>{static_cast<size_t>(D)});
      current_statement__ = 3;
      context__.validate_dims("parameter initialization", "beta", "double",
        std::vector<size_t>{static_cast<size_t>(L), static_cast<size_t>(D)});
      int pos__ = std::numeric_limits<int>::min();
      pos__ = 1;
      std::vector<local_scalar_t__> mu =
        std::vector<local_scalar_t__>(D, DUMMY_VAR__);
      current_statement__ = 1;
      mu = context__.vals_r("mu");
      out__.write(mu);
      std::vector<local_scalar_t__> sigma =
        std::vector<local_scalar_t__>(D, DUMMY_VAR__);
      current_statement__ = 2;
      sigma = context__.vals_r("sigma");
      out__.write_free_lb(0, sigma);
      std::vector<Eigen::Matrix<local_scalar_t__,-1,1>> beta =
        std::vector<Eigen::Matrix<local_scalar_t__,-1,1>>(L,
          Eigen::Matrix<local_scalar_t__,-1,1>::Constant(D, DUMMY_VAR__));
      {
        std::vector<local_scalar_t__> beta_flat__;
        current_statement__ = 3;
        beta_flat__ = context__.vals_r("beta");
        current_statement__ = 3;
        pos__ = 1;
        current_statement__ = 3;
        for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
          current_statement__ = 3;
          for (int sym2__ = 1; sym2__ <= L; ++sym2__) {
            current_statement__ = 3;
            stan::model::assign(beta, beta_flat__[(pos__ - 1)],
              "assigning variable beta", stan::model::index_uni(sym2__),
              stan::model::index_uni(sym1__));
            current_statement__ = 3;
            pos__ = (pos__ + 1);
          }
        }
      }
      out__.write(beta);
    } catch (const std::exception& e) {
      stan::lang::rethrow_located(e, locations_array__[current_statement__]);
    }
  }
  inline void
  get_param_names(std::vector<std::string>& names__, const bool
                  emit_transformed_parameters__ = true, const bool
                  emit_generated_quantities__ = true) const {
    names__ = std::vector<std::string>{"mu", "sigma", "beta"};
    if (emit_transformed_parameters__) {}
    if (emit_generated_quantities__) {
      std::vector<std::string>
        temp{"mu_prior", "sigma_prior", "p_prior", "p_predicted",
             "p_predicted_default", "p_predicted_intervention",
             "predicted_difference", "status_diff"};
      names__.reserve(names__.size() + temp.size());
      names__.insert(names__.end(), temp.begin(), temp.end());
    }
  }
  inline void
  get_dims(std::vector<std::vector<size_t>>& dimss__, const bool
           emit_transformed_parameters__ = true, const bool
           emit_generated_quantities__ = true) const {
    dimss__ = std::vector<std::vector<size_t>>{std::vector<size_t>{static_cast<
                                                                    size_t>(D)},
                std::vector<size_t>{static_cast<size_t>(D)},
                std::vector<size_t>{static_cast<size_t>(L),
                  static_cast<size_t>(D)}};
    if (emit_transformed_parameters__) {}
    if (emit_generated_quantities__) {
      std::vector<std::vector<size_t>>
        temp{std::vector<size_t>{static_cast<size_t>(D)},
             std::vector<size_t>{static_cast<size_t>(D)},
             std::vector<size_t>{static_cast<size_t>(N)},
             std::vector<size_t>{static_cast<size_t>(N)},
             std::vector<size_t>{static_cast<size_t>(Nx)},
             std::vector<size_t>{static_cast<size_t>(Nx)},
             std::vector<size_t>{static_cast<size_t>(Nx)},
             std::vector<size_t>{static_cast<size_t>(L)}};
      dimss__.reserve(dimss__.size() + temp.size());
      dimss__.insert(dimss__.end(), temp.begin(), temp.end());
    }
  }
  inline void
  constrained_param_names(std::vector<std::string>& param_names__, bool
                          emit_transformed_parameters__ = true, bool
                          emit_generated_quantities__ = true) const final {
    for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
      param_names__.emplace_back(std::string() + "mu" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
      param_names__.emplace_back(std::string() + "sigma" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
      for (int sym2__ = 1; sym2__ <= L; ++sym2__) {
        param_names__.emplace_back(std::string() + "beta" + '.' +
          std::to_string(sym2__) + '.' + std::to_string(sym1__));
      }
    }
    if (emit_transformed_parameters__) {}
    if (emit_generated_quantities__) {
      for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
        param_names__.emplace_back(std::string() + "mu_prior" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
        param_names__.emplace_back(std::string() + "sigma_prior" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= N; ++sym1__) {
        param_names__.emplace_back(std::string() + "p_prior" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= N; ++sym1__) {
        param_names__.emplace_back(std::string() + "p_predicted" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= Nx; ++sym1__) {
        param_names__.emplace_back(std::string() + "p_predicted_default" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= Nx; ++sym1__) {
        param_names__.emplace_back(std::string() + "p_predicted_intervention"
          + '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= Nx; ++sym1__) {
        param_names__.emplace_back(std::string() + "predicted_difference" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= L; ++sym1__) {
        param_names__.emplace_back(std::string() + "status_diff" + '.' +
          std::to_string(sym1__));
      }
    }
  }
  inline void
  unconstrained_param_names(std::vector<std::string>& param_names__, bool
                            emit_transformed_parameters__ = true, bool
                            emit_generated_quantities__ = true) const final {
    for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
      param_names__.emplace_back(std::string() + "mu" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
      param_names__.emplace_back(std::string() + "sigma" + '.' +
        std::to_string(sym1__));
    }
    for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
      for (int sym2__ = 1; sym2__ <= L; ++sym2__) {
        param_names__.emplace_back(std::string() + "beta" + '.' +
          std::to_string(sym2__) + '.' + std::to_string(sym1__));
      }
    }
    if (emit_transformed_parameters__) {}
    if (emit_generated_quantities__) {
      for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
        param_names__.emplace_back(std::string() + "mu_prior" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= D; ++sym1__) {
        param_names__.emplace_back(std::string() + "sigma_prior" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= N; ++sym1__) {
        param_names__.emplace_back(std::string() + "p_prior" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= N; ++sym1__) {
        param_names__.emplace_back(std::string() + "p_predicted" + '.' +
          std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= Nx; ++sym1__) {
        param_names__.emplace_back(std::string() + "p_predicted_default" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= Nx; ++sym1__) {
        param_names__.emplace_back(std::string() + "p_predicted_intervention"
          + '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= Nx; ++sym1__) {
        param_names__.emplace_back(std::string() + "predicted_difference" +
          '.' + std::to_string(sym1__));
      }
      for (int sym1__ = 1; sym1__ <= L; ++sym1__) {
        param_names__.emplace_back(std::string() + "status_diff" + '.' +
          std::to_string(sym1__));
      }
    }
  }
  inline std::string get_constrained_sizedtypes() const {
    return std::string("[{\"name\":\"mu\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(D) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"sigma\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(D) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(L) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(D) + "}},\"block\":\"parameters\"},{\"name\":\"mu_prior\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(D) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"sigma_prior\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(D) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"p_prior\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(N) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"p_predicted\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(N) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"p_predicted_default\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(Nx) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"p_predicted_intervention\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(Nx) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"predicted_difference\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(Nx) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"status_diff\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(L) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"}]");
  }
  inline std::string get_unconstrained_sizedtypes() const {
    return std::string("[{\"name\":\"mu\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(D) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"sigma\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(D) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"parameters\"},{\"name\":\"beta\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(L) + ",\"element_type\":{\"name\":\"vector\",\"length\":" + std::to_string(D) + "}},\"block\":\"parameters\"},{\"name\":\"mu_prior\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(D) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"sigma_prior\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(D) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"p_prior\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(N) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"p_predicted\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(N) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"p_predicted_default\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(Nx) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"p_predicted_intervention\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(Nx) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"predicted_difference\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(Nx) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"},{\"name\":\"status_diff\",\"type\":{\"name\":\"array\",\"length\":" + std::to_string(L) + ",\"element_type\":{\"name\":\"real\"}},\"block\":\"generated_quantities\"}]");
  }
  // Begin method overload boilerplate
  template <typename RNG> inline void
  write_array(RNG& base_rng, Eigen::Matrix<double,-1,1>& params_r,
              Eigen::Matrix<double,-1,1>& vars, const bool
              emit_transformed_parameters = true, const bool
              emit_generated_quantities = true, std::ostream*
              pstream = nullptr) const {
    const size_t num_params__ = ((D + D) + (L * D));
    const size_t num_transformed = emit_transformed_parameters * (0);
    const size_t num_gen_quantities = emit_generated_quantities * ((((((((D +
      D) + N) + N) + Nx) + Nx) + Nx) + L));
    const size_t num_to_write = num_params__ + num_transformed +
      num_gen_quantities;
    std::vector<int> params_i;
    vars = Eigen::Matrix<double,-1,1>::Constant(num_to_write,
             std::numeric_limits<double>::quiet_NaN());
    write_array_impl(base_rng, params_r, params_i, vars,
      emit_transformed_parameters, emit_generated_quantities, pstream);
  }
  template <typename RNG> inline void
  write_array(RNG& base_rng, std::vector<double>& params_r, std::vector<int>&
              params_i, std::vector<double>& vars, bool
              emit_transformed_parameters = true, bool
              emit_generated_quantities = true, std::ostream*
              pstream = nullptr) const {
    const size_t num_params__ = ((D + D) + (L * D));
    const size_t num_transformed = emit_transformed_parameters * (0);
    const size_t num_gen_quantities = emit_generated_quantities * ((((((((D +
      D) + N) + N) + Nx) + Nx) + Nx) + L));
    const size_t num_to_write = num_params__ + num_transformed +
      num_gen_quantities;
    vars = std::vector<double>(num_to_write,
             std::numeric_limits<double>::quiet_NaN());
    write_array_impl(base_rng, params_r, params_i, vars,
      emit_transformed_parameters, emit_generated_quantities, pstream);
  }
  template <bool propto__, bool jacobian__, typename T_> inline T_
  log_prob(Eigen::Matrix<T_,-1,1>& params_r, std::ostream* pstream = nullptr) const {
    Eigen::Matrix<int,-1,1> params_i;
    return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
  }
  template <bool propto__, bool jacobian__, typename T_> inline T_
  log_prob(std::vector<T_>& params_r, std::vector<int>& params_i,
           std::ostream* pstream = nullptr) const {
    return log_prob_impl<propto__, jacobian__>(params_r, params_i, pstream);
  }
  inline void
  transform_inits(const stan::io::var_context& context,
                  Eigen::Matrix<double,-1,1>& params_r, std::ostream*
                  pstream = nullptr) const final {
    std::vector<double> params_r_vec(params_r.size());
    std::vector<int> params_i;
    transform_inits(context, params_i, params_r_vec, pstream);
    params_r = Eigen::Map<Eigen::Matrix<double,-1,1>>(params_r_vec.data(),
                 params_r_vec.size());
  }
  inline void
  transform_inits(const stan::io::var_context& context, std::vector<int>&
                  params_i, std::vector<double>& vars, std::ostream*
                  pstream__ = nullptr) const {
    vars.resize(num_params_r__);
    transform_inits_impl(context, vars, pstream__);
  }
  inline void
  unconstrain_array(const std::vector<double>& params_constrained,
                    std::vector<double>& params_unconstrained, std::ostream*
                    pstream = nullptr) const {
    const std::vector<int> params_i;
    params_unconstrained = std::vector<double>(num_params_r__,
                             std::numeric_limits<double>::quiet_NaN());
    unconstrain_array_impl(params_constrained, params_i,
      params_unconstrained, pstream);
  }
  inline void
  unconstrain_array(const Eigen::Matrix<double,-1,1>& params_constrained,
                    Eigen::Matrix<double,-1,1>& params_unconstrained,
                    std::ostream* pstream = nullptr) const {
    const std::vector<int> params_i;
    params_unconstrained = Eigen::Matrix<double,-1,1>::Constant(num_params_r__,
                             std::numeric_limits<double>::quiet_NaN());
    unconstrain_array_impl(params_constrained, params_i,
      params_unconstrained, pstream);
  }
};
}
using stan_model = modela5f78e2459e__namespace::modela5f78e2459e_;
#ifndef USING_R
// Boilerplate
stan::model::model_base&
new_model(stan::io::var_context& data_context, unsigned int seed,
          std::ostream* msg_stream) {
  stan_model* m = new stan_model(data_context, seed, msg_stream);
  return *m;
}
stan::math::profile_map& get_stan_profile_data() {
  return modela5f78e2459e__namespace::profiles__;
}
#endif
#endif