def constraint_black(gradients, rect_shape=(6, 6)):
    start_point = (random.randint(0, (gradients.shape[1] - rect_shape[0])), random.randint(0, (gradients.shape[2] - rect_shape[1])))
    new_grads = np.zeros_like(gradients)
    patch = gradients[:, start_point[0]:(start_point[0] + rect_shape[0]), start_point[1]:(start_point[1] + rect_shape[1])]
    if (np.mean(patch) < 0):
        new_grads[:, start_point[0]:(start_point[0] + rect_shape[0]), start_point[1]:(start_point[1] + rect_shape[1])] = (- np.ones_like(patch))
    return new_grads
def constraint_black(gradients, rect_shape=(6, 6)):
    start_point = (random.randint(0, (gradients.shape[1] - rect_shape[0])), random.randint(0, (gradients.shape[2] - rect_shape[1])))
    new_grads = np.zeros_like(gradients)
    patch = gradients[:, start_point[0]:(start_point[0] + rect_shape[0]), start_point[1]:(start_point[1] + rect_shape[1])]
    if (np.mean(patch) < 0):
        new_grads[:, start_point[0]:(start_point[0] + rect_shape[0]), start_point[1]:(start_point[1] + rect_shape[1])] = (- np.ones_like(patch))
    return new_grads