def normalize(tensor, target_mean=0, target_std=1):
    """Shifts the input to have a target mean and target standard deviation.
    """
    return target_mean + (tensor - tensor.mean())*(target_std/(tensor.std() + 1e-7))