def _get_fine_reduced_mask(
        self,
        x: np.ndarray,
        x_noise: np.ndarray,
        x_tar_noise: np.ndarray,
        y: int,
        mask: np.ndarray,
        patches: list[np.ndarray],
        xforms: list,
        object_size: float,
        clip_min: float,
        clip_max: float,
        lbd: float = 5,
        pts: np.ndarray | None = None,
    ) -> np.ndarray:
        """
        Function to finely reduce mask.

        :param x: An array with one original input to be attacked.
        :param x_noise: x in the resolution of the noise size.
        :param x_tar_noise: x_tar in the resolution of the noise size.
        :param y: The target label.
        :param mask: An array with a mask to be applied to the adversarial perturbations. Shape needs to be
                     broadcastable to the shape of x. Any features for which the mask is zero will not be adversarially
                     perturbed.
        :param patches: List of patches from heatmap.
        :param xforms: List of transform params.
        :param obj_size: Estimated width of object in inches for perspective transform.
        :param clip_min: Minimum value of an example.
        :param clip_max: Maximum value of an example.
        :param lbd: Weight for mask scoring function.
        :param pts: Optional. A set of points that will set the crop size in the perspective transform.
        :return: mask
        """
        # STAGE 3: Fine reduction
        theta = (x_tar_noise - x_noise) * mask

        # get initial transform_robustness
        xform_imgs = get_transformed_images(x, mask, xforms, 1.0, theta, self.net_size, clip_min, clip_max, pts)

        success_rate = run_predictions(self.estimator, xform_imgs, y, self.batch_size, False)

        init_tr_err = 1 - success_rate

        best_score = score_fn(mask, init_tr_err, object_size, threshold=(1 - self.tr_lo), lbd=lbd)
        best_mask = mask

        new_patches = []
        j = 0
        # iterate over patches, greedily remove if the score improves
        while patches:
            j = j + 1

            # highest transform_robustness is now always at end, for pop()
            next_patch = patches.pop()
            if np.max(next_patch * best_mask) == 0:
                continue
            next_mask = best_mask * (np.ones(best_mask.shape) - next_patch)
            theta = (x_tar_noise - x_noise) * next_mask

            xform_imgs = get_transformed_images(
                x, next_mask, xforms, 1.0, theta, self.net_size, clip_min, clip_max, pts
            )

            success_rate = run_predictions(self.estimator, xform_imgs, y, self.batch_size, False)

            score = score_fn(next_mask, 1 - success_rate, object_size, threshold=(1 - self.tr_lo), lbd=lbd)
            if score < best_score:
                best_score = score
                best_mask = next_mask
                nbits = best_mask.sum() / best_mask.shape[-1]
                if self.max_mask_size > 0 and nbits < self.max_mask_size:
                    break
            else:
                new_patches.append(next_patch)

        return best_mask

        Function to finely reduce mask.

        :param x: An array with one original input to be attacked.
        :param x_noise: x in the resolution of the noise size.
        :param x_tar_noise: x_tar in the resolution of the noise size.
        :param y: The target label.
        :param mask: An array with a mask to be applied to the adversarial perturbations. Shape needs to be
                     broadcastable to the shape of x. Any features for which the mask is zero will not be adversarially
                     perturbed.
        :param patches: List of patches from heatmap.
        :param xforms: List of transform params.
        :param obj_size: Estimated width of object in inches for perspective transform.
        :param clip_min: Minimum value of an example.
        :param clip_max: Maximum value of an example.
        :param lbd: Weight for mask scoring function.
        :param pts: Optional. A set of points that will set the crop size in the perspective transform.
        :return: mask
        
art/attacks/evasion/graphite/graphite_blackbox.py