import torch


def repackage_var(h):
    """Wraps h in new Variables, to detach them from their history."""
    return (
        h.detach()
        if type(h) == torch.Tensor
        else tuple(repackage_var(v) for v in h))