def resize(img_list, box_list=None, min_size=None, max_size=None):
    assert (type(min_size) in (int, tuple)), f'The type of min_size_train shoule be int or tuple, got {type(min_size)}.'
    if isinstance(min_size, tuple):
        min_size = random.randint(min_size[0], min_size[1])
    assert (img_list.img.size == img_list.ori_size), 'img size error when resizing.'
    (w, h) = img_list.ori_size
    (short_side, long_side) = (min(w, h), max(w, h))
    if (((min_size / short_side) * long_side) > max_size):
        scale = (max_size / long_side)
    else:
        scale = (min_size / short_side)
    (new_h, new_w) = (int((scale * h)), int((scale * w)))
    assert ((min(new_h, new_w) <= min_size) and (max(new_h, new_w) <= max_size)), 'Scale error when resizing.'
    resized_img = F.resize(img_list.img, (new_h, new_w))
    img_list.img = resized_img
    img_list.resized_size = (new_w, new_h)
    if (box_list is None):
        return img_list
    else:
        box_list.resize(new_size=(new_w, new_h))
    return (img_list, box_list)
def resize(img_list, box_list=None, min_size=None, max_size=None):
    assert (type(min_size) in (int, tuple)), f'The type of min_size_train shoule be int or tuple, got {type(min_size)}.'
    if isinstance(min_size, tuple):
        min_size = random.randint(min_size[0], min_size[1])
    assert (img_list.img.size == img_list.ori_size), 'img size error when resizing.'
    (w, h) = img_list.ori_size
    (short_side, long_side) = (min(w, h), max(w, h))
    if (((min_size / short_side) * long_side) > max_size):
        scale = (max_size / long_side)
    else:
        scale = (min_size / short_side)
    (new_h, new_w) = (int((scale * h)), int((scale * w)))
    assert ((min(new_h, new_w) <= min_size) and (max(new_h, new_w) <= max_size)), 'Scale error when resizing.'
    resized_img = F.resize(img_list.img, (new_h, new_w))
    img_list.img = resized_img
    img_list.resized_size = (new_w, new_h)
    if (box_list is None):
        return img_list
    else:
        box_list.resize(new_size=(new_w, new_h))
    return (img_list, box_list)