boxes is expected to have the shape [batch_size, 4] so that boxes.unbind(1) returns the min and max values for both dimensions.
However, in your code it seems that boxes only contains a single dimension, so you might need to unsqueeze the batch dimension.
Also, which batch size are you currently using?