import torch


def check_bounds(myt, imsize):
    """
    Given a list of 2D points (x-y coordinates) and an image size, return
    a boolean vector indicating which points are out of the image boundary

    Parameters
    ----------
    myt : torch.Tensor
        (k,2) matrix of 2D points
    imsize : tuple or torch.Size
        image size; H x W

    Returns
    -------
    out : (k,) Byte tensor
        vector indicating which points are out of bounds
    """
    xt = myt[:,0]
    yt = myt[:,1]
    x_out = (torch.floor(xt) < 0) | (torch.ceil(xt) >= imsize[0])
    y_out = (torch.floor(yt) < 0) | (torch.ceil(yt) >= imsize[1])
    out = x_out | y_out

    return out