              masks3 = [orig_masks, *pred_masks]
          else:
              masks3 = np.repeat(np.expand_dims(orig_masks, axis=0), 3, axis=0)
  
          retval = [np.array([cv2.addWeighted(img, 1.0, mask, 0.3, 0)
                              for img, mask in zip(previews, compiled_masks)])
                    for previews, compiled_masks in zip(faces, masks3)]
          logger.debug("masked shapes: %s", [faces.shape for faces in retval])
          return retval
  
      @classmethod
      def _overlay_foreground(cls, backgrounds: np.ndarray, foregrounds: np.ndarray) -> np.ndarray:
 
</s> remove             pred_masks = [np.tile(1 - np.rint(face[..., -1])[..., None], 3) for face in faces[-2:]]
            for swap_masks in pred_masks:
                swap_masks[np.where((swap_masks == [1., 1., 1.]).all(axis=3))] = [0., 0., 1.]
 </s> add             pred_masks = [1 - np.rint(face[..., -1])[..., None] for face in faces[-2:]] </s> remove     @classmethod
    def _compile_masked(cls, faces: List[np.ndarray], masks: np.ndarray) -> List[np.ndarray]:
 </s> add     def _compile_masked(self, faces: List[np.ndarray], masks: np.ndarray) -> List[np.ndarray]: </s> remove             func = self.config.get
        retval = func(section, option)
 </s> add             retval = self.config.get(section, option)
 </s> remove         indices = np.where(randoms > int(self._config.get("random_flip", 50)) / 100)[0]
 </s> add         flip_chance = self._config.get("random_flip", 50)
        assert isinstance(flip_chance, int)
        indices = np.where(randoms > flip_chance / 100)[0] </s> remove             func = self._parse_list
 </s> add             retval = self._parse_list(section, option)
        retval: List[np.ndarray] = []
        alpha = 1.0 - self._mask_opacity
        for previews, compiled_masks in zip(faces, masks3):
            overlays = previews.copy()
            overlays[np.where((compiled_masks == 1.).all(axis=3))] = self._mask_color
            retval.append(np.array([cv2.addWeighted(img, alpha, ovl, self._mask_opacity, 0)
                                    for img, ovl in zip(previews, overlays)]))

              masks3 = [orig_masks, *pred_masks]
          else:
              masks3 = np.repeat(np.expand_dims(orig_masks, axis=0), 3, axis=0)
  
        retval: List[np.ndarray] = []
        alpha = 1.0 - self._mask_opacity
        for previews, compiled_masks in zip(faces, masks3):
            overlays = previews.copy()
            overlays[np.where((compiled_masks == 1.).all(axis=3))] = self._mask_color
            retval.append(np.array([cv2.addWeighted(img, alpha, ovl, self._mask_opacity, 0)
                                    for img, ovl in zip(previews, overlays)]))

        retval: List[np.ndarray] = []
        alpha = 1.0 - self._mask_opacity
        for previews, compiled_masks in zip(faces, masks3):
            overlays = previews.copy()
            overlays[np.where((compiled_masks == 1.).all(axis=3))] = self._mask_color
            retval.append(np.array([cv2.addWeighted(img, alpha, ovl, self._mask_opacity, 0)
                                    for img, ovl in zip(previews, overlays)]))

        retval: List[np.ndarray] = []
        alpha = 1.0 - self._mask_opacity
        for previews, compiled_masks in zip(faces, masks3):
            overlays = previews.copy()
            overlays[np.where((compiled_masks == 1.).all(axis=3))] = self._mask_color
            retval.append(np.array([cv2.addWeighted(img, alpha, ovl, self._mask_opacity, 0)
                                    for img, ovl in zip(previews, overlays)]))

          logger.debug("masked shapes: %s", [faces.shape for faces in retval])
          return retval
  
      @classmethod
      def _overlay_foreground(cls, backgrounds: np.ndarray, foregrounds: np.ndarray) -> np.ndarray:
keep keep keep keep replace replace replace keep keep keep keep keep
 Preview - Allow mask color/opacity configuration
  - typing: lib.config
  - docs: lib.config
  - bugfix: popup_configure - keep assets on top 
plugins/train/trainer/_base.py