          mask = preprocessing_func(mask)
      mask_as_k_inv_prop = 1 - mask_prop
      mask = (mask * mask_prop) + mask_as_k_inv_prop
  
      def inner_loss(y_true, y_pred):
          # Branching because tensorflows broadcasting is wonky and
          # plaidmls concatenate is implemented ineficient.
          if K.backend() == "plaidml.keras.backend":
              n_true = y_true * mask
              n_pred = y_pred * mask
          else:
              n_true = K.concatenate([y_true[:, :, :, i:i+1] * mask for i in range(3)], axis=-1)
 
</s> remove     return inner_loss
 </s> add     return _inner_loss </s> remove     mask = scale_mask(mask, mask_scaling)
 </s> add     mask = _scale_mask(mask, mask_scaling) </s> remove     def make_kernel(sigma):
 </s> add     def _make_kernel(sigma):
        """ Make the gaussian kernel. """ </s> remove     """ From https://github.com/iperov/DeepFaceLab
        Used for blurring mask in training """
    def gaussian(var_x, radius, sigma):
 </s> add     """ Apply gaussian blur to an input.

    Used for blurring mask in training.

    Parameters
    ----------
    radius: float, optional
        The kernel radius for applying gaussian blur. Default: `2.0`

    Returns
    -------
    tensor
        The input tensor with gaussian blurring applied

    References
    ----------
    https://github.com/iperov/DeepFaceLab
    """
    def _gaussian(var_x, radius, sigma):
        """ Obtain the gaussian kernel. """ </s> remove 
    def scale_mask(mask, scaling):
        """ Scale the input mask to be the same size as the input face """
 </s> add     def _scale_mask(mask, scaling):
        """ Scale the input mask to be the same size as the input face

        Parameters
        ----------
        mask: input tensor
            The mask for the current image
        scaling: float
            The amount to scale the input mask by

        Returns
        -------
        tensor
            The resized input mask
        """
    def _inner_loss(y_true, y_pred):
        """ Apply the loss function to the masked area of the image.

         Parameters
        ----------
        y_true: tensor or variable
            The ground truth value
        y_pred: tensor or variable
            The predicted value

        Returns
        -------
        tensor
            The Loss value

        Notes
        -----
        Branching because TensorFlow's broadcasting is wonky and plaidML's concatenate is
        implemented inefficiently.
        """
          mask = preprocessing_func(mask)
      mask_as_k_inv_prop = 1 - mask_prop
      mask = (mask * mask_prop) + mask_as_k_inv_prop
  
    def _inner_loss(y_true, y_pred):
        """ Apply the loss function to the masked area of the image.

         Parameters
        ----------
        y_true: tensor or variable
            The ground truth value
        y_pred: tensor or variable
            The predicted value

        Returns
        -------
        tensor
            The Loss value

        Notes
        -----
        Branching because TensorFlow's broadcasting is wonky and plaidML's concatenate is
        implemented inefficiently.
        """
    def _inner_loss(y_true, y_pred):
        """ Apply the loss function to the masked area of the image.

         Parameters
        ----------
        y_true: tensor or variable
            The ground truth value
        y_pred: tensor or variable
            The predicted value

        Returns
        -------
        tensor
            The Loss value

        Notes
        -----
        Branching because TensorFlow's broadcasting is wonky and plaidML's concatenate is
        implemented inefficiently.
        """
    def _inner_loss(y_true, y_pred):
        """ Apply the loss function to the masked area of the image.

         Parameters
        ----------
        y_true: tensor or variable
            The ground truth value
        y_pred: tensor or variable
            The predicted value

        Returns
        -------
        tensor
            The Loss value

        Notes
        -----
        Branching because TensorFlow's broadcasting is wonky and plaidML's concatenate is
        implemented inefficiently.
        """
          if K.backend() == "plaidml.keras.backend":
              n_true = y_true * mask
              n_pred = y_pred * mask
          else:
              n_true = K.concatenate([y_true[:, :, :, i:i+1] * mask for i in range(3)], axis=-1)
keep keep keep keep replace replace replace keep keep keep keep keep
 Simple backend unit tests (#1020)

* Add simple backend tests for lib.model
* Document lib.model
* Fix GMSD Loss for AMD
* Remove obsolete code from lib.model 
lib/model/losses.py