              faces = self._process_legacy(filename, image, faces)
  
          for idx, face in enumerate(faces):
              output = f"{frame_name}_{idx}.png"
              meta = dict(alignments=face.to_png_meta(),
                          source=dict(alignments_version=self._alignments.version,
                                      original_filename=output,
                                      face_index=idx,
                                      source_filename=filename,
                                      source_is_video=self._frames.is_video,
                                      source_frame_dims=image.shape[:2]))
              self._saver.save(output, encode_image(face.aligned.face, ".png", metadata=meta))
              if self._min_size == 0 and self._is_legacy:
                  face.thumbnail = generate_thumbnail(face.aligned.face, size=96, quality=60)
                  self._alignments.data[filename]["faces"][idx] = face.to_alignment()
              face_count += 1
 
</s> remove         seen: dict[str, list[int]] = {}
 </s> add         seen: Dict[str, List[int]] = {} </s> remove def layer_test(layer_cls, kwargs={}, input_shape=None, input_dtype=None,
 </s> add def layer_test(layer_cls, kwargs={}, input_shape=None, input_dtype=None,  # noqa:C901 </s> remove         reader = imageio.get_reader(self._args.input_dir, "ffmpeg")
        for i, frame in enumerate(reader):
 </s> add         reader = imageio.get_reader(self._args.input_dir, "ffmpeg")  # type:ignore[arg-type]
        for i, frame in enumerate(cast(Iterator[np.ndarray], reader)): </s> remove                     logger.trace("Selected for redetection: '%s'", key)  # type: ignore
 </s> add                     logger.trace("Selected for redetection: '%s'",  # type:ignore[attr-defined]
                                 key) </s> remove         retval: list[str] = []
 </s> add         retval: List[str] = []
            meta: PNGHeaderDict = dict(
                alignments=face.to_png_meta(),
                source=dict(alignments_version=self._alignments.version,
                            original_filename=output,
                            face_index=idx,
                            source_filename=filename,
                            source_is_video=self._frames.is_video,
                            source_frame_dims=cast(Tuple[int, int], image.shape[:2])))
            assert face.aligned.face is not None
              faces = self._process_legacy(filename, image, faces)
  
          for idx, face in enumerate(faces):
              output = f"{frame_name}_{idx}.png"
            meta: PNGHeaderDict = dict(
                alignments=face.to_png_meta(),
                source=dict(alignments_version=self._alignments.version,
                            original_filename=output,
                            face_index=idx,
                            source_filename=filename,
                            source_is_video=self._frames.is_video,
                            source_frame_dims=cast(Tuple[int, int], image.shape[:2])))
            assert face.aligned.face is not None
            meta: PNGHeaderDict = dict(
                alignments=face.to_png_meta(),
                source=dict(alignments_version=self._alignments.version,
                            original_filename=output,
                            face_index=idx,
                            source_filename=filename,
                            source_is_video=self._frames.is_video,
                            source_frame_dims=cast(Tuple[int, int], image.shape[:2])))
            assert face.aligned.face is not None
            meta: PNGHeaderDict = dict(
                alignments=face.to_png_meta(),
                source=dict(alignments_version=self._alignments.version,
                            original_filename=output,
                            face_index=idx,
                            source_filename=filename,
                            source_is_video=self._frames.is_video,
                            source_frame_dims=cast(Tuple[int, int], image.shape[:2])))
            assert face.aligned.face is not None
            meta: PNGHeaderDict = dict(
                alignments=face.to_png_meta(),
                source=dict(alignments_version=self._alignments.version,
                            original_filename=output,
                            face_index=idx,
                            source_filename=filename,
                            source_is_video=self._frames.is_video,
                            source_frame_dims=cast(Tuple[int, int], image.shape[:2])))
            assert face.aligned.face is not None
            meta: PNGHeaderDict = dict(
                alignments=face.to_png_meta(),
                source=dict(alignments_version=self._alignments.version,
                            original_filename=output,
                            face_index=idx,
                            source_filename=filename,
                            source_is_video=self._frames.is_video,
                            source_frame_dims=cast(Tuple[int, int], image.shape[:2])))
            assert face.aligned.face is not None
            meta: PNGHeaderDict = dict(
                alignments=face.to_png_meta(),
                source=dict(alignments_version=self._alignments.version,
                            original_filename=output,
                            face_index=idx,
                            source_filename=filename,
                            source_is_video=self._frames.is_video,
                            source_frame_dims=cast(Tuple[int, int], image.shape[:2])))
            assert face.aligned.face is not None
            meta: PNGHeaderDict = dict(
                alignments=face.to_png_meta(),
                source=dict(alignments_version=self._alignments.version,
                            original_filename=output,
                            face_index=idx,
                            source_filename=filename,
                            source_is_video=self._frames.is_video,
                            source_frame_dims=cast(Tuple[int, int], image.shape[:2])))
            assert face.aligned.face is not None
              self._saver.save(output, encode_image(face.aligned.face, ".png", metadata=meta))
              if self._min_size == 0 and self._is_legacy:
                  face.thumbnail = generate_thumbnail(face.aligned.face, size=96, quality=60)
                  self._alignments.data[filename]["faces"][idx] = face.to_alignment()
              face_count += 1
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep
 tests:
  - unit test: tools.alignments.media
  - Add mypy test
  - Typing fixes 
tools/alignments/jobs_frames.py