      loss = K.mean(loss, axis=-1) * beta
      return loss
  
  
  def l_p_norm(y_true, y_pred, p_norm=np.inf):
      """
      Calculate the L-p norm as a loss function,
      valid choics of p are [0,1,no.inf]
      """
      diff = y_true - y_pred
      loss = tf.norm(diff, ord=p_norm, axis=-1)
      return loss
  
  
  def l_inf_norm(y_true, y_pred):
      """ Calculate the L-inf norm as a loss function """
      diff = K.abs(y_true - y_pred)
      max_loss = K.max(diff, axis=(1, 2), keepdims=True)
      loss = K.mean(max_loss, axis=-1)
 
</s> remove     """ Calculate the L-inf norm as a loss function """
 </s> add     """ Calculate the L-inf norm as a loss function.

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

    Returns
    -------
    tensor
        The loss value
    """ </s> remove     """
    generalized function used to return a large variety of mathematical loss functions
    primary benefit is smooth, differentiable version of L1 loss

    Barron, J. A More General Robust Loss Function
    https://arxiv.org/pdf/1701.03077.pdf
    Parameters:
        alpha: penalty factor. larger number give larger weight to large deviations
        beta: scale factor used to adjust to the input scale (i.e. inputs of mean 1e-4 or 256 )
    Return:
        a loss value from the results of function(y_pred - y_true)
    Example:
        a=1.0, x>>c , c=1.0/255.0 will give a smoothly differentiable version of L1 / MAE loss
        a=1.999999 (lim as a->2), beta=1.0/255.0 will give L2 / RMSE loss
 </s> add     """ Generalized function used to return a large variety of mathematical loss functions.

    The primary benefit is a smooth, differentiable version of L1 loss.

    Parameters
    ----------
    y_true: tensor or variable
        The ground truth value
    y_pred: tensor or variable
        The predicted value
    alpha: float, optional
        Penalty factor. Larger number give larger weight to large deviations. Default: `1.0`
    beta: float, optional
        Scale factor used to adjust to the input scale (i.e. inputs of mean `1e-4` or `256`).
        Default: `1.0/255.0`

    Returns
    -------
    tensor
        The loss value from the results of function(y_pred - y_true)

    References
    ----------
    Barron, J. A More General Robust Loss Function - https://arxiv.org/pdf/1701.03077.pdf

    Example
    -------
    >>> a=1.0, x>>c , c=1.0/255.0  # will give a smoothly differentiable version of L1 / MAE loss
    >>> a=1.999999 (limit as a->2), beta=1.0/255.0 # will give L2 / RMSE loss </s> remove     """ A wrapper for mask loss that can perform pre-processing on the input
        prior to calling the loss function
        loss_func: The loss function to use
        preprocessing_func: The preprocessing function to use. Should take a Keras Input
        as it's only argument """

 </s> add     """ A wrapper for mask loss that can perform pre-processing on the input prior to calling the
    loss function.

    Parameters
    ----------
    loss_func: class or function
        The actual loss function to use
    preprocessing_func: function
        The pre-processing function to use. Should take a Keras Input as it's only argument
    """ </s> remove     def inner_loss(y_true, y_pred):
        # Branching because tensorflows broadcasting is wonky and
        # plaidmls concatenate is implemented ineficient.
 </s> add     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.
        """ </s> remove     def diff_x(img):
 </s> add     def _diff_x(img):
        """ X Difference """
      loss = K.mean(loss, axis=-1) * beta
      return loss
  
  










  def l_inf_norm(y_true, y_pred):
      """ Calculate the L-inf norm as a loss function """
      diff = K.abs(y_true - y_pred)
      max_loss = K.max(diff, axis=(1, 2), keepdims=True)
      loss = K.mean(max_loss, axis=-1)
keep keep keep keep replace replace replace replace replace replace replace 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