      return loss
  
  
  def scharr_edges(image, magnitude):
      """
      Returns a tensor holding modified Scharr edge maps.
      Arguments:
      image: Image tensor with shape [batch_size, h, w, d] and type float32.
      The image(s) must be 2x2 or larger.
      magnitude: Boolean to determine if the edge magnitude or edge direction is returned
      Returns:
      Tensor holding edge maps for each channel. Returns a tensor with shape
      [batch_size, h, w, d, 2] where the last two dimensions hold [[dy[0], dx[0]],
      [dy[1], dx[1]], ..., [dy[d-1], dx[d-1]]] calculated using the Scharr filter.
      """
  
      # Define vertical and horizontal Scharr filters.
      static_image_shape = image.get_shape()
      image_shape = K.shape(image)
 
</s> remove     static_image_shape = image.get_shape()
 </s> add     static_image_shape = image.shape.dims if get_backend() == "amd" else image.get_shape() </s> remove     padded = tf.pad(image, pad_sizes, mode='REFLECT')
 </s> add     padded = pad(image, pad_sizes, mode='REFLECT') </s> remove     def __int_shape(x):
        return K.int_shape(x)
 </s> add     def __int_shape(input_tensor):
        """ Returns the shape of tensor or variable as a tuple of int or None entries.

        Parameters
        ----------
        input_tensor: tensor or variable
            The input to return the shape for

        Returns
        -------
        tuple
            A tuple of integers (or None entries)
        """
        return K.int_shape(input_tensor) </s> remove         output = tf.atan(K.squeeze(output[:, :, :, :, 0] / output[:, :, :, :, 1]))
    # magnitude of edges -- unified x & y edges don't work well with NN

 </s> add         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 </s> remove     matrix = [[[[0.00070, 0.00070]],
               [[0.00520, 0.00370]],
               [[0.03700, 0.00000]],
               [[0.00520, -0.0037]],
               [[0.00070, -0.0007]]],
              [[[0.00370, 0.00520]],
               [[0.11870, 0.11870]],
               [[0.25890, 0.00000]],
               [[0.11870, -0.1187]],
               [[0.00370, -0.0052]]],
              [[[0.00000, 0.03700]],
               [[0.00000, 0.25890]],
               [[0.00000, 0.00000]],
               [[0.00000, -0.2589]],
               [[0.00000, -0.0370]]],
              [[[-0.0037, 0.00520]],
               [[-0.1187, 0.11870]],
               [[-0.2589, 0.00000]],
               [[-0.1187, -0.1187]],
               [[-0.0037, -0.0052]]],
              [[[-0.0007, 0.00070]],
               [[-0.0052, 0.00370]],
               [[-0.0370, 0.00000]],
               [[-0.0052, -0.0037]],
               [[-0.0007, -0.0007]]]]
 </s> add     matrix = np.array([[[[0.00070, 0.00070]],
                        [[0.00520, 0.00370]],
                        [[0.03700, 0.00000]],
                        [[0.00520, -0.0037]],
                        [[0.00070, -0.0007]]],
                       [[[0.00370, 0.00520]],
                        [[0.11870, 0.11870]],
                        [[0.25890, 0.00000]],
                        [[0.11870, -0.1187]],
                        [[0.00370, -0.0052]]],
                       [[[0.00000, 0.03700]],
                        [[0.00000, 0.25890]],
                        [[0.00000, 0.00000]],
                        [[0.00000, -0.2589]],
                        [[0.00000, -0.0370]]],
                       [[[-0.0037, 0.00520]],
                        [[-0.1187, 0.11870]],
                        [[-0.2589, 0.00000]],
                        [[-0.1187, -0.1187]],
                        [[-0.0037, -0.0052]]],
                       [[[-0.0007, 0.00070]],
                        [[-0.0052, 0.00370]],
                        [[-0.0370, 0.00000]],
                        [[-0.0052, -0.0037]],
                        [[-0.0007, -0.0007]]]])
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
      return loss
  
  
  def scharr_edges(image, magnitude):
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
    """ Returns a tensor holding modified Scharr edge maps.

    Parameters
    ----------
    image: tensor
        Image tensor with shape [batch_size, h, w, d] and type float32. The image(s) must be 2x2
        or larger.
    magnitude: bool
        Boolean to determine if the edge magnitude or edge direction is returned

    Returns
    -------
    tensor
        Tensor holding edge maps for each channel. Returns a tensor with shape `[batch_size, h, w,
        d, 2]` where the last two dimensions hold `[[dy[0], dx[0]], [dy[1], dx[1]], ..., [dy[d-1],
        dx[d-1]]]` calculated using the Scharr filter.
      """
  
      # Define vertical and horizontal Scharr filters.
      static_image_shape = image.get_shape()
      image_shape = K.shape(image)
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