IOU Metric from dice function gives negative

I have defined a loss function using the dice IOU function:

def IOU(input, target):
    return dice(input, target, iou=True)

For some reason, I am getting negative IOU values when training (see image below). My understanding of the IOU metric is that it is a positive value and a good result is greater than or equal to 0.5.
1565566517

Am I doing something wrong?

I also met the same problem