Symbol ''for loop''

How can I do something similar to following code using mxnet symbol:

y = mx.sym.var('y')
x = mx.sym.var('x')
output = 1.0
for i in range(y):
    if i > 1 and i < 5:
        output = output * x

You could use the foreach operator that allows to run a for-loop over symbols. The operator is part of the contrib package:

Could you plz provide the code that can do what I want?