def get_mixer(p=0.5, s_l=0.02, s_h=0.4, r_1=0.3, r_2=(1 / 0.3)):

    def mixer(img1, img2, mask1, mask2):
        (img_h, img_w, img_c) = img1.shape
        p_1 = np.random.rand()
        if (p_1 > p):
            return (img1, mask1)
        while True:
            s = ((np.random.uniform(s_l, s_h) * img_h) * img_w)
            r = np.random.uniform(r_1, r_2)
            w = int(np.sqrt((s / r)))
            h = int(np.sqrt((s * r)))
            left = np.random.randint(0, img_w)
            top = np.random.randint(0, img_h)
            if (((left + w) <= img_w) and ((top + h) <= img_h)):
                break
        img1[top:(top + h), left:(left + w), :] = img2[top:(top + h), left:(left + w), :]
        mask1[top:(top + h), left:(left + w), :] = mask2[top:(top + h), left:(left + w), :]
        return (img1, mask1)
    return mixer
def get_mixer(p=0.5, s_l=0.02, s_h=0.4, r_1=0.3, r_2=(1 / 0.3)):

    def mixer(img1, img2, mask1, mask2):
        (img_h, img_w, img_c) = img1.shape
        p_1 = np.random.rand()
        if (p_1 > p):
            return (img1, mask1)
        while True:
            s = ((np.random.uniform(s_l, s_h) * img_h) * img_w)
            r = np.random.uniform(r_1, r_2)
            w = int(np.sqrt((s / r)))
            h = int(np.sqrt((s * r)))
            left = np.random.randint(0, img_w)
            top = np.random.randint(0, img_h)
            if (((left + w) <= img_w) and ((top + h) <= img_h)):
                break
        img1[top:(top + h), left:(left + w), :] = img2[top:(top + h), left:(left + w), :]
        mask1[top:(top + h), left:(left + w), :] = mask2[top:(top + h), left:(left + w), :]
        return (img1, mask1)
    return mixer