import torch


def point_form(boxes, img_ratio):
    """ Convert prior_boxes to (xmin, ymin, xmax, ymax)
    """
    # boxes[:, :2] represent the center_x and center_y
    ratio_coefficiency = torch.Tensor([[1.0, 1.0, img_ratio, 1.0]]).repeat(boxes.size(0), 1)
    if boxes.is_cuda:
        ratio_coefficiency = ratio_coefficiency.cuda()
    boxes = boxes / ratio_coefficiency
    return torch.cat((boxes[:, :2] - boxes[:, 2:]/2, boxes[:, :2] + boxes[:, 2:]/2), 1)