'Propose cropping areas'

def _random_crop_proposal(self, label, height, width):

    from math import sqrt
    if ((not self.enabled) or (height <= 0) or (width <= 0)):
        return None
    min_area = ((self.area_range[0] * height) * width)
    max_area = ((self.area_range[1] * height) * width)
    for _ in range(self.max_attempts):
        ratio = random.uniform(*self.aspect_ratio_range)
        if (ratio <= 0):
            continue
        h = int(round(sqrt((min_area / ratio))))
        max_h = int(round(sqrt((max_area / ratio))))
        if (round((max_h * ratio)) > width):
            max_h = int(((width + 0.4999999) / ratio))
        if (max_h > height):
            max_h = height
        if (h > max_h):
            h = max_h
        if (h < max_h):
            h = random.randint(h, max_h)
        w = int(round((h * ratio)))
        assert (w <= width)
        area = (w * h)
        if (area < min_area):
            h += 1
            w = int(round((h * ratio)))
            area = (w * h)
        if (area > max_area):
            h -= 1
            w = int(round((h * ratio)))
            area = (w * h)
        if ((area < min_area) or (area > max_area) or (w > width) or (h > height) or (w <= 0) or (h <= 0)):
            continue
        y = random.randint(0, max(0, (height - h)))
        x = random.randint(0, max(0, (width - w)))
        if self._check_satisfy_constraints(label, x, y, (x + w), (y + h), width, height):
            new_label = self._update_labels(label, (x, y, w, h), height, width)
            if (new_label is not None):
                return (x, y, w, h, new_label)
    return None
