Sorry yesterday I make several mistakes. There is fixed prototype:
hidden_size = 4
compressed_size = 3
input_size = 5
batch_size = 1

prior = nn.Linear(hidden_size, compressed_size * 2)
dec = nn.Linear(hidden_size + compressed_size, input_size)
state = Variable(torch.ones(batch_size, hidden_size))
result = Variable(torch.ones(3, input_size))
def myfunc():
   z_prior = prior(state)
   z = Variable(torch.randn(batch_size, compressed_size)) * z_prior[:,compressed_size:].exp() + z_prior[:, :compressed_size]
   return dec(torch.cat([state, z], dim=1))

for i in range(3):
    result[i] = myfunc()