          """
          logger.debug("Checking faces exist in alignments")
          missing_alignments = dict()
          for side, train_hashes in self._hashes.items():
              align_hashes = set(face.hash for face in self._detected_faces[side])
              if not align_hashes.issuperset(train_hashes["hashes"]):
                  missing_alignments[side] = [
                      os.path.basename(filename)
                      for hsh, filename in zip(train_hashes["hashes"], train_hashes["filenames"])
                      if hsh not in align_hashes]
          if missing_alignments:
 
</s> remove                     for hsh, filename in zip(train_hashes["hashes"], train_hashes["filenames"])
 </s> add                     for hsh, filenames in train_hashes.items()
                    for filename in filenames </s> remove         side_hashes = set(self._hashes[side]["hashes"])
        detected_faces = []
 </s> add         dupe_count = 0
        side_hashes = set(self._hashes[side])
        detected_faces = dict() </s> remove         side_hashes = self._hashes[side]
        hash_indices = [idx for idx, hsh in enumerate(side_hashes["hashes"]) if hsh == face_hash]
        retval = [side_hashes["filenames"][idx] for idx in hash_indices]
 </s> add         retval = self._hashes[side][face_hash] </s> remove     # Load alignments
 </s> add     def _get_masks(self, side, detected_faces):
        """ For each face, obtain the mask and set the requested blurring and threshold level.

        Parameters
        ----------
        side: {"a" or "b"}
            The side currently being processed
        detected_faces: dict
            Key is the hash of the face, value is the corresponding
            :class:`lib.faces_detect.DetectedFace` object

        Returns
        -------
        dict
            The face filenames as keys with the :class:`lib.faces_detect.Mask` as value.
        """

        masks = dict()
        for fhash, face in detected_faces.items():
            mask = face.mask[self._training_opts["mask_type"]]
            mask.set_blur_kernel_and_threshold(blur_kernel=self._training_opts["mask_blur_kernel"],
                                               threshold=self._training_opts["mask_threshold"])
            for filename in self._hash_to_filenames(side, fhash):
                masks[filename] = mask
        return masks

    # Pre flight checks
    def _check_alignments_exist(self):
        """ Ensure the alignments files exist prior to running any longer running tasks.

        Raises
        ------
        FaceswapError
            If at least one alignments file does not exist
        """
        for fullpath in self._training_opts["alignments"].values():
            if not os.path.exists(fullpath):
                raise FaceswapError("Alignments file does not exist: `{}`".format(fullpath))

    # Hashes for image folders
            align_hashes = set(self._detected_faces[side])
            if not align_hashes.issuperset(set(train_hashes)):
          """
          logger.debug("Checking faces exist in alignments")
          missing_alignments = dict()
          for side, train_hashes in self._hashes.items():
            align_hashes = set(self._detected_faces[side])
            if not align_hashes.issuperset(set(train_hashes)):
            align_hashes = set(self._detected_faces[side])
            if not align_hashes.issuperset(set(train_hashes)):
                  missing_alignments[side] = [
                      os.path.basename(filename)
                      for hsh, filename in zip(train_hashes["hashes"], train_hashes["filenames"])
                      if hsh not in align_hashes]
          if missing_alignments:
keep keep keep keep replace replace keep keep keep keep keep
 plugins.train.trainer - Speed up mask caching 
plugins/train/trainer/_base.py