import torch


def dist_step2(BGAN, ImDist, ticks, refvec, tanvec, refimg):
    """Compute the Image distance when travel `ticks` distance along `tanvec` from `refvec`
    refimg is provided to save computation."""
    step_latents = torch.tensor(ticks).float().cuda().view(-1, 1) @ tanvec + refvec
    with torch.no_grad():
        step_imgs = BGAN.generator(step_latents, 0.7)
        step_imgs = (step_imgs + 1.0) / 2.0
        dist_steps = ImDist(step_imgs, refimg).squeeze()
    return dist_steps.squeeze().cpu().numpy(), step_imgs