import torch


def space_motor_to_img(pt):
    """
    Translate all control points from spline space to image space.
    Changes all points (x, -y) -> (y, x)

    Parameters
    ----------
    pt : torch.Tensor
        (..., 2) spline point sequence for each sub-stroke

    Returns
    -------
    new_pt : torch.Tensor
        (..., 2) image point sequence for each sub-stroke
    """
    assert torch.is_tensor(pt)
    space_flip = torch.tensor([-1.,1.], device=pt.device)
    new_pt = torch.flip(pt, dims=[-1]) * space_flip

    return new_pt