      k_1: float, optional
          Parameter of the SSIM. Default: `0.01`
      k_2: float, optional
          Parameter of the SSIM. Default: `0.03`
      kernel_size: int, optional
          Size of the sliding window Default: `3`
      max_value: float, optional
          Max value of the output. Default: `1.0`
  
      Notes
      ------
 
</s> remove     Difference of Structural Similarity (DSSIM loss function). Clipped between 0 and 0.5
 </s> add     Difference of Structural Similarity (DSSIM loss function). </s> remove         title += " - {}".format(text) if text is not None and text else ""
 </s> add         title += f" - {text}" if text is not None and text else "" </s> remove         if padding == 'same':
            padding = 'SAME'
        elif padding == 'valid':
            padding = 'VALID'
        else:
            raise ValueError('Invalid padding:', padding)
        return padding

    def extract_image_patches(self, input_tensor, k_sizes, s_sizes,
                              padding='same', data_format='channels_last'):
        """ Extract the patches from an image.

        Parameters
        ----------
        input_tensor: tensor
            The input image
        k_sizes: tuple
            2-d tuple with the kernel size
        s_sizes: tuple
            2-d tuple with the strides size
        padding: str, optional
            `"same"` or `"valid"`. Default: `"same"`
        data_format: str, optional.
            `"channels_last"` or `"channels_first"`. Default: `"channels_last"`

        Returns
        -------
        The (k_w, k_h) patches extracted
            Tensorflow ==> (batch_size, w, h, k_w, k_h, c)
            Theano ==> (batch_size, w, h, c, k_w, k_h)
        """
        kernel = [1, k_sizes[0], k_sizes[1], 1]
        strides = [1, s_sizes[0], s_sizes[1], 1]
        padding = self._preprocess_padding(padding)
        if data_format == 'channels_first':
            input_tensor = K.permute_dimensions(input_tensor, (0, 2, 3, 1))
        patches = tf.image.extract_patches(input_tensor, kernel, strides, [1, 1, 1, 1], padding)
        return patches


class GeneralizedLoss(tf.keras.losses.Loss):
 </s> add         ssim = tf.image.ssim(y_true,
                             y_pred,
                             self.max_value,
                             filter_size=self.filter_size,
                             filter_sigma=self.filter_sigma,
                             k1=self.k_1,
                             k2=self.k_2)
        dssim_loss = 1. - ssim
        return dssim_loss


class GeneralizedLoss(tf.keras.losses.Loss):  # pylint:disable=too-few-public-methods </s> remove         if not data:
            logger.debug("No data to cache")
            return
 </s> add  </s> remove     msg = "{}  has been deprecated and will be removed from a future update.".format(function)
 </s> add     msg = f"{function}  has been deprecated and will be removed from a future update."
    filter_size: int, optional
        size of gaussian filter Default: `11`
    filter_sigma: float, optional
        Width of gaussian filter Default: `1.5`
      k_1: float, optional
          Parameter of the SSIM. Default: `0.01`
      k_2: float, optional
          Parameter of the SSIM. Default: `0.03`
    filter_size: int, optional
        size of gaussian filter Default: `11`
    filter_sigma: float, optional
        Width of gaussian filter Default: `1.5`
    filter_size: int, optional
        size of gaussian filter Default: `11`
    filter_sigma: float, optional
        Width of gaussian filter Default: `1.5`
      max_value: float, optional
          Max value of the output. Default: `1.0`
  
      Notes
      ------
keep keep keep keep replace replace keep keep keep keep keep
 Update code to support Tensorflow versions up to 2.8 (#1213)

* Update maximum tf version in setup + requirements

* - bump max version of tf version in launcher
- standardise tf version check

* update keras get_custom_objects  for tf>2.6

* bugfix: force black text in GUI file dialogs (linux)

* dssim loss - Move to stock tf.ssim function

* Update optimizer imports for compatibility

* fix logging for tf2.8

* Fix GUI graphing for TF2.8

* update tests

* bump requirements.txt versions

* Remove limit on nvidia-ml-py

* Graphing bugfixes
  - Prevent live graph from displaying if data not yet available

* bugfix: Live graph. Collect loss labels correctly

* fix: live graph - swallow inconsistent loss errors

* Bugfix: Prevent live graph from clearing during training

* Fix graphing for AMD 
lib/model/losses_tf.py