import torch


def shearx_grid(output_size, ulim=(-1, 1), vlim=(-5, 5), out=None, device=None):
    """Horizontal shear coordinate system.
    
    Args:
        output_size: (int, int), number of sampled values for the v-coordinate and u-coordinate respectively
        ulim: (float, float), Cartesian y-coordinate limits
        vlim: (float, float), x/y ratio limits
        out: torch.FloatTensor, output tensor
        device: string or torch.device, device for torch.tensor
        
    Returns:
        torch.FloatTensor, shape (output_size[0], output_size[1], 2), tensor where entry (i,j) gives the
        (x, y)-coordinates of the grid point.
    """
    nv, nu = output_size
    urange = torch.linspace(ulim[0], ulim[1], nu, device=device)
    vrange = torch.linspace(vlim[0], vlim[1], nv, device=device)
    vs, us = torch.meshgrid([vrange, urange])
    ys = us
    xs = us * vs
    return torch.stack([xs, ys], 2, out=out)