          """
          model_inputs = []
          model_targets = []
          for side in ("a", "b"):
              side_inputs, side_targets = self._get_next(side)
              if self._model.config["penalized_mask_loss"]:
                  side_targets = self._compile_masks(side_targets)
                  if not self._model.config["learn_mask"]:  # Remove masks from the model targets
                      side_targets = side_targets[:-1]
              logger.trace("side: %s, input_shapes: %s, target_shapes: %s",
                           side, [i.shape for i in side_inputs], [i.shape for i in side_targets])
              if get_backend() == "amd":
                  model_inputs.extend(side_inputs)
                  model_targets.extend(side_targets)
 
</s> remove             self._masks[side] = batch["masks"][0]
 </s> add             self._masks[side] = batch["masks"] </s> remove         masks = targets[-1]
        for idx, tgt in enumerate(targets[:-1]):
 </s> add         if not self._model.config["penalized_mask_loss"] and additional_masks is None:
            logger.trace("No masks to compile. Returning targets")
            return targets

        if not self._model.config["penalized_mask_loss"] and additional_masks is not None:
            masks = additional_masks
        elif additional_masks is not None:
            masks = np.concatenate((masks, additional_masks), axis=-1)

        for idx, tgt in enumerate(targets): </s> remove     def _get_next(self, side):
        """ Return the next batch from the :class:`lib.training_data.TrainingDataGenerator` for
        this feeder ready for feeding into the model.

        Returns
        -------
        model_inputs: list
            A list of :class:`numpy.ndarray` for feeding into the model
        model_targets: list
            A list of :class:`numpy.ndarray` for comparing the output of the model
        """
        logger.trace("Generating targets")
        batch = next(self._feeds[side])
        targets_use_mask = (self._model.config["learn_mask"]
                            or self._model.config["penalized_mask_loss"])
        model_targets = batch["targets"] + batch["masks"] if targets_use_mask else batch["targets"]
        return batch["feed"], model_targets

    @classmethod
    def _compile_masks(cls, targets):
        """ Compile the masks into the targets for penalized loss.
 </s> add     def _compile_mask_targets(self, targets, masks, additional_masks):
        """ Compile the masks into the targets for penalized loss and for targeted learning. </s> remove         logger.trace("masks shape: %s", masks.shape)
        batch = np.concatenate((batch, masks), axis=-1)
 </s> add         Returns
        -------
        :class:`numpy.ndarray`
            The batch with masks applied to the final channels
        """
        logger.trace("Input batch shape: %s, side: %s", batch.shape, side)
        size = batch.shape[1]
        for key in ("masks", "eyes", "mouths"):
            item = self._masks[key]
            if item is None and key != "masks":
                continue
            if item is None and key == "masks":
                logger.trace("Creating dummy masks. side: %s", side)
                masks = np.ones_like(batch[..., :1], dtype=batch.dtype)
            else:
                logger.trace("Obtaining masks for batch. (key: %s side: %s)", key, side)
                masks = np.array([self._get_mask(item[side][filename], size)
                                  for filename, face in zip(filenames, batch)], dtype=batch.dtype)
                masks = self._resize_masks(size, masks)

            logger.trace("masks: (key: %s, shape: %s)", key, masks.shape)
            batch = np.concatenate((batch, masks), axis=-1) </s> remove                                       for mask in masks])[..., None]
 </s> add                                       for mask in masks])
                if add_masks.ndim == 3:
                    add_masks = add_masks[..., None]
            batch = next(self._feeds[side])
            side_inputs = batch["feed"]
            side_targets = self._compile_mask_targets(batch["targets"],
                                                      batch["masks"],
                                                      batch.get("additional_masks", None))
            if self._model.config["learn_mask"]:
                side_targets = side_targets + [batch["masks"]]
          """
          model_inputs = []
          model_targets = []
          for side in ("a", "b"):
            batch = next(self._feeds[side])
            side_inputs = batch["feed"]
            side_targets = self._compile_mask_targets(batch["targets"],
                                                      batch["masks"],
                                                      batch.get("additional_masks", None))
            if self._model.config["learn_mask"]:
                side_targets = side_targets + [batch["masks"]]
            batch = next(self._feeds[side])
            side_inputs = batch["feed"]
            side_targets = self._compile_mask_targets(batch["targets"],
                                                      batch["masks"],
                                                      batch.get("additional_masks", None))
            if self._model.config["learn_mask"]:
                side_targets = side_targets + [batch["masks"]]
            batch = next(self._feeds[side])
            side_inputs = batch["feed"]
            side_targets = self._compile_mask_targets(batch["targets"],
                                                      batch["masks"],
                                                      batch.get("additional_masks", None))
            if self._model.config["learn_mask"]:
                side_targets = side_targets + [batch["masks"]]
            batch = next(self._feeds[side])
            side_inputs = batch["feed"]
            side_targets = self._compile_mask_targets(batch["targets"],
                                                      batch["masks"],
                                                      batch.get("additional_masks", None))
            if self._model.config["learn_mask"]:
                side_targets = side_targets + [batch["masks"]]
            batch = next(self._feeds[side])
            side_inputs = batch["feed"]
            side_targets = self._compile_mask_targets(batch["targets"],
                                                      batch["masks"],
                                                      batch.get("additional_masks", None))
            if self._model.config["learn_mask"]:
                side_targets = side_targets + [batch["masks"]]
              logger.trace("side: %s, input_shapes: %s, target_shapes: %s",
                           side, [i.shape for i in side_inputs], [i.shape for i in side_targets])
              if get_backend() == "amd":
                  model_inputs.extend(side_inputs)
                  model_targets.extend(side_targets)
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 Add Mouth and Eye Priority to Loss options (#1054)

* Priority Training for Mouth and Eyes - Tensorflow

* Use chosen loss function for area multipliers

* loss multipliers for AMD

* Fix mask multipliers for plaid and roll PenalizedMaskLoss into LossWrapper

* losses_tf: roll PenalizedMaskLoss into LossWrapper 
plugins/train/trainer/_base.py