              blur_kernel=self._size // 16,
              as_zip=True)
  
  
  class TrainingDataGenerator():  # pylint:disable=too-few-public-methods
      """ A Training Data Generator for compiling data for feeding to a model.
  
      This class is called from :mod:`plugins.train.trainer._base` and launches a background
      iterator that compiles augmented data, target data and sample data.
  
 
</s> remove         if not self._config["penalized_mask_loss"] or self._config[f"{area}_multiplier"] <= 1:
            return
        key = "eyes" if area == "eye" else area

        logger.trace("Caching localized '%s' mask for: %s", key, filename)
        self._cache[os.path.basename(filename)][f"mask_{key}"] = detected_face.get_landmark_mask(
            self._size,
            key,
            aligned=True,
            centering=self._centering,
            dilation=self._size // 32,
            blur_kernel=self._size // 16,
            as_zip=True)
 </s> add         return ne.evaluate("x / c",
                           local_dict=dict(x=in_array, c=np.float32(255)),
                           casting="unsafe") </s> remove     It would probably be quicker to set locks on each individual face, but for code complexity
    reasons, and the fact that the lock is only taken up during cache population, and it should
    only be being read multiple times on save iterations, we lock the whole cache during writes.
 </s> add     This class is called from :mod:`plugins.train.trainer._base` and launches a background
    iterator that compiles augmented data, target data and sample data. </s> remove         If the configuration options `eye_multiplier` and/or `mouth_multiplier` are greater than 1
        then these masks are applied to the final channels of the batch respectively.
 </s> add     This class is called from :mod:`plugins.train.trainer._base` and launches a background
    iterator that compiles sample preview data for feeding the model's predict function and for
    display.

    Parameters
    ----------
    model: :class:`~plugins.train.model.ModelBase`
        The model that this data generator is feeding
    config: dict
        The configuration `dict` generated from :file:`config.train.ini` containing the trainer
        plugin configuration options.
    side: {'a' or 'b'}
        The side of the model that this iterator is for.
    images: list
        A list of image paths that will be used to compile the final images.
    batch_size: int
        The batch size for this iterator. Images will be returned in :class:`numpy.ndarray`
        objects of this size from the iterator.
    """
    def _create_samples(self,
                        images: np.ndarray,
                        detected_faces: List[DetectedFace]) -> List[np.ndarray]:
        """ Compile the 'sample' images. These are the 100% coverage images which hold the model
        output in the preview window. </s> remove         The exit point from this class and the sole attribute that should be referenced. Called
        from :mod:`plugins.train.trainer._base`. Returns an iterator that yields images for
        training, preview and time-lapses.
 </s> add     def _create_targets(self, batch: np.ndarray) -> List[np.ndarray]:
        """ Compile target images, with masks, for the model output sizes. </s> remove     model_input_size: int
        The expected input size for the model. It is assumed that the input to the model is always
        a square image. This is the size, in pixels, of the `width` and the `height` of the input
        to the model.
    model_output_shapes: list
        A list of tuples defining the output shapes from the model, in the order that the outputs
        are returned. The tuples should be in (`height`, `width`, `channels`) format.
    coverage_ratio: float
        The ratio of the training image to be trained on. Dictates how much of the image will be
        cropped out. E.G: a coverage ratio of 0.625 will result in cropping a 160px box from a
        256px image (:math:`256 * 0.625 = 160`).
    color_order: ["rgb", "bgr"]
        The color order that the model expects as input
    augment_color: bool
        ``True`` if color is to be augmented, otherwise ``False``
    no_flip: bool
        ``True`` if the image shouldn't be randomly flipped as part of augmentation, otherwise
        ``False``
    no_warp: bool
        ``True`` if the image shouldn't be warped as part of augmentation, otherwise ``False``
    warp_to_landmarks: bool
        ``True`` if the random warp method should warp to similar landmarks from the other side,
        ``False`` if the standard random warp method should be used.
    face_cache: dict
        A thread safe dictionary containing a cache of information relating to all faces being
        trained on
 </s> add     model: :class:`~plugins.train.model.ModelBase`
        The model that this data generator is feeding
class TrainingDataGenerator(DataGenerator):  # pylint:disable=too-few-public-methods
              blur_kernel=self._size // 16,
              as_zip=True)
  
  
class TrainingDataGenerator(DataGenerator):  # pylint:disable=too-few-public-methods
      """ A Training Data Generator for compiling data for feeding to a model.
  
      This class is called from :mod:`plugins.train.trainer._base` and launches a background
      iterator that compiles augmented data, target data and sample data.
  
keep keep keep keep replace keep keep keep keep keep
 Data Augmentation update (#1263)

- lib.detected_face
    - Subclass Masks for Landmark based masks
    - Add training mask propery + methods to DetectedFace
  - lib.training_training
    - subclass TrainingDataGenerator for training and preview data
    - Split cache into own module
    - Reduce thread count to 1 to prevent image corruption + data re-use
    - Process on largest model input/output size rather than stored image size
    - Size and crop masks during caching stage
    - Implement ring buffer for data flow
    - Fix preview reload bug
  - augmentation
    - typing
    - switch color aug order
    - better initialization
    - Fix warp + landmark warp to correctly apply at different image scales
    - Slightly improved warp caching
    - Don't store whether image is_preview. Handle all data as training images implicitly
  - plugins.trainer: Typing and fixes to work with trainingdata refactor 
lib/training/generator.py