          # Reshape to [batch_size, h, w, d, num_kernels].
          shape = K.concatenate([image_shape, num_kernels], axis=0)
          output = K.reshape(output, shape=shape)
          output.set_shape(static_image_shape.concatenate(num_kernels))
          output = tf.atan(K.squeeze(output[:, :, :, :, 0] / output[:, :, :, :, 1]))
      # magnitude of edges -- unified x & y edges don't work well with NN
  
      return output
  
  
  def gmsd_loss(y_true, y_pred):
      """
 
</s> remove     padded = tf.pad(image, pad_sizes, mode='REFLECT')
 </s> add     padded = pad(image, pad_sizes, mode='REFLECT') </s> remove     def diff_y(img):
 </s> add     def _diff_y(img):
        """ Y Difference """ </s> remove     def diff_xx(img):
 </s> add     def _diff_xx(img):
        """ X-X Difference """ </s> remove     """
    Calculates the first and second order gradient difference between pixels of
    an image in the x and y dimensions. These gradients are then compared between
    the ground truth and the predicted image and the difference is taken. When
    used as a loss, its minimization will result in predicted images approaching
    the same level of sharpness / blurriness as the ground truth.

    TV+TV2 Regularization with Nonconvex Sparseness-Inducing Penalty
    for Image Restoration, Chengwu Lu & Hua Huang, 2014
    (http://downloads.hindawi.com/journals/mpe/2014/790547.pdf)

    Parameters:
        y_true: The predicted frames at each scale
        y_true: The ground truth frames at each scale
    Return:
        The GD loss
 </s> add     """ Gradient Loss Function.

    Calculates the first and second order gradient difference between pixels of an image in the x
    and y dimensions. These gradients are then compared between the ground truth and the predicted
    image and the difference is taken. When used as a loss, its minimization will result in
    predicted images approaching the same level of sharpness / blurriness as the ground truth.

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

    Returns
    -------
    tensor
        The loss value

    References
    ----------
    TV+TV2 Regularization with Non-Convex Sparseness-Inducing Penalty for Image Restoration,
    Chengwu Lu & Hua Huang, 2014 - http://downloads.hindawi.com/journals/mpe/2014/790547.pdf </s> remove     def diff_yy(img):
 </s> add     def _diff_yy(img):
        """ Y-Y Difference """
        output = tf.atan(K.squeeze(output[:, :, :, :, 0] / output[:, :, :, :, 1], axis=None))
    # magnitude of edges -- unified x & y edges don't work well with Neural Networks
          # Reshape to [batch_size, h, w, d, num_kernels].
          shape = K.concatenate([image_shape, num_kernels], axis=0)
          output = K.reshape(output, shape=shape)
          output.set_shape(static_image_shape.concatenate(num_kernels))
        output = tf.atan(K.squeeze(output[:, :, :, :, 0] / output[:, :, :, :, 1], axis=None))
    # magnitude of edges -- unified x & y edges don't work well with Neural Networks
        output = tf.atan(K.squeeze(output[:, :, :, :, 0] / output[:, :, :, :, 1], axis=None))
    # magnitude of edges -- unified x & y edges don't work well with Neural Networks
        output = tf.atan(K.squeeze(output[:, :, :, :, 0] / output[:, :, :, :, 1], axis=None))
    # magnitude of edges -- unified x & y edges don't work well with Neural Networks
      return output
  
  
  def gmsd_loss(y_true, y_pred):
      """
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