import torch


def reparameterize(mu, log_var):
    """ Implements the 'reparameterization trick'
    """

    std = torch.exp(0.5*log_var)  # standard deviation
    eps = torch.randn_like(std)  # `randn_like` as we need the same size
    sample = mu + (eps * std)  # sampling as if coming from the input space
    return sample