def compute_features_locations(h, w, stride, dtype=torch.float32, device='cpu', offset="none"):
    """Adapted from AdelaiDet:
        https://github.com/aim-uofa/AdelaiDet/blob/master/adet/utils/comm.py

    Key differnece: offset is configurable.
    """
    shifts_x = torch.arange(0, w * stride, step=stride, dtype=dtype, device=device)
    shifts_y = torch.arange(0, h * stride, step=stride, dtype=dtype, device=device)
    shift_y, shift_x = torch.meshgrid(shifts_y, shifts_x)
    shift_x = shift_x.reshape(-1)
    shift_y = shift_y.reshape(-1)
    # (dennis.park)
    # locations = torch.stack((shift_x, shift_y), dim=1) + stride // 2
    locations = torch.stack((shift_x, shift_y), dim=1)
    if offset == "half":
        locations += stride // 2
    else:
        assert offset == "none"

    return locations
Adapted from AdelaiDet:
        https://github.com/aim-uofa/AdelaiDet/blob/master/adet/utils/comm.py

    Key differnece: offset is configurable.
    
tridet/utils/tensor2d.py