The jit cannot trace through sizes (they’re just tuples, and torch can strictly only trace tensors). In your case, you can use the _like functions.
If you allow me to say so, the coding style of that function is heavily dated. Don’t use Variable or torch.FloatTensor (and neither .data)!
Here would be a modern version:
def reparametrize(mu, logvar):
  std = logvar.mul(0.5).exp_()
  eps = torch.normal(torch.zeros_like(mu))
  return eps.mul(std).add_(mu)

Now, it might be more natural to write eps = torch.èmpty_like_(mu).normal_(), but the jit hicked on that for me.
You’ll have to trace that with check_trace=False because of the random bits. Also you need a torch version post mid-September.
So
fn = torch.jit.trace(reparametrize, (torch.zeros(3), torch.zeros(3)) , check_trace=False)
m = torch.zeros(3, requires_grad=True)
lv = torch.zeros(3, requires_grad=True)
fn(m, lv).sum().backward()
print(m.grad)
print(lv.grad)

Best regards
Thomas