I am trying to use reduce_sum to speed up estimation using within chain parallelization.

I have created the function to be used in reduce_sum as shown in vignette in stan manual.

However upon executing the code throws error stating the fuction does not exist.

```
functions {
real partial_sum(int[] y_slice,
int start,
int end,
matrix x1,
matrix x2,
vector beta,
matrix rbeta,
int J,
int[] ll) {
return bernoulli_logit_lpmf(y_slice[start:end] |x1[start:end,:] * beta + (x2[start:end,:] .* rbeta[ll[start:end],:]) * rep_vector(1,J));
}
}
data {
int<lower=0> N;//Number of observations
int<lower=1> J;//Number of predictors with random slope
int<lower=1> K;//Number of predictors with non-random slope
int<lower=1> L;//Number of customers/groups
int<lower=0,upper=1> y[N];//Binary response variable
int<lower=1,upper=L> ll[N];//Number of observations in groups
matrix[N,K] x1;
matrix[N,J] x2;
}
parameters {
vector[J] rbeta_mu; //mean of distribution of beta parameters
vector<lower=0>[J] rbeta_sigma; //variance of distribution of beta parameters
vector[J] beta_raw[L]; //group-specific parameters beta
vector[K] beta;
}
transformed parameters {
vector[J] rbeta[L];
for (l in 1:L)
rbeta[l] = rbeta_mu + rbeta_sigma .* beta_raw[l]; // coefficients on x
}
model {
rbeta_mu ~ normal(0,100);
rbeta_sigma ~ cauchy(0,10);
beta~normal(0,10);
for (l in 1:L)
beta_raw[l] ~ normal(0,1);
target += reduce_sum(partial_sum,y,1,x1,x2,beta,rbeta,J,ll);
}
```

I get the following erroer:

Any help with resolving this is greatly appreciated.