Unexpected behavior of torchvision.ops.nms

Following the example below and looking the nms source code, I expected a NaN error, as the intersection and union will be zero.

import torchvision  # torchvision==0.5.0+cpu
import torch        # torch==1.4.0+cpu

boxes = [[0.0, 0.0, 1.0, 1.0],
          [2.0, 1.0, 1.0, 2.0]]

boxes = torch.tensor(boxes)
scores = torch.tensor([1., 0.5])

keep = torchvision.ops.nms(boxes, scores, 0.7)

If this same example is used with this nms implementation (removing the +1 from the source code to be equivalent to the torchvision implementation), it raises a NaN error as expected.

Am I missing something ?
Thanks.

I opened this github issue and it was answered and solved.