Lambert transformation in user defined function to generate random numbers

Hello I would like to transcribe r function to generate random numbers in stan. But, I am getting error in stan. The function works fine in r.
Following is the function i created in r
rUL = function(n, par)
{
library(lamW)
u = runif(n)
a=1+par+lambertWm1((1+par)(exp(-(1+par)))(u-1))
b = 1+lambertWm1((1+par)(exp(-(1+par)))(u-1))
d=a/b
return(d)
}
I would like to transcribe above function in stan. I have used following user defined function but it is giving me error.

functions{
real rUL_rng(real par)
{
real a=1+par+lambert_wm1((1+par)(exp(-(1+par)))(uniform_rng(0,1)-1));
real b = 1+lambert_wm1((1+par)(exp(-(1+par)))(uniform_rng(0,1)-1));
real d=a/b;
return(d);
}
}
I am getting following error:
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
No matches for:

lambert_wm1(real)

Function lambert_wm1 not found.

I’m not sure if there’s something preventing functions that use random numbers to be defined, since random numbers can only be used in the generated quantities block, but you could check by writing the same function without the random number to test, or alternatively writing the rng code in the generated quantities block as a procedural block instead of a function.