          name = "{}_{}".format(name, self.names[name])
          logger.debug("Generating block name: %s", name)
          return name
  
      def set_default_initializer(self, kwargs):
          """ Sets the default initializer for conv2D and Seperable conv2D layers
              to conv_aware or he_uniform().
              if a specific initializer has been passed in then the specified initializer
              will be used rather than the default """
          if "kernel_initializer" in kwargs:
              logger.debug("Using model specified initializer: %s", kwargs["kernel_initializer"])
              return kwargs
          if self.use_convaware_init:
              default = ConvolutionAware()
 
</s> remove     def switch_kernel_initializer(kwargs, initializer):
        """ Switch the initializer in the given kwargs to the given initializer
            and return the previous initializer to caller """
 </s> add     def _switch_kernel_initializer(kwargs, initializer):
        """ Switch the initializer in the given kwargs to the given initializer and return the
        previous initializer to caller.

        For residual blocks and up-scaling, user selected initializer methods should replace those
        set by the model. This method updates the initializer for the layer, and returns the
        original initializer so that it can be set back to the layer's key word arguments for
        subsequent layers where the initializer should not be switched.

        Parameters
        ----------
        kwargs: dict
            The keyword arguments for the current layer
        initializer: keras or faceswap initializer class
            The initializer that should replace the current initializer that exists in keyword
            arguments

        Returns
        -------
        keras or faceswap initializer class
            The original initializer that existed in the given keyword arguments
        """ </s> remove     def get_name(self, name):
        """ Return unique layer name for requested block """
 </s> add     def _get_name(self, name):
        """ Return unique layer name for requested block.

        As blocks can be used multiple times, auto appends an integer to the end of the requested
        name to keep all block names unique

        Parameters
        ----------
        name: str
            The requested name for the layer

        Returns
        -------
        str
            The unique name for this layer
        """ </s> remove     """ Blocks to use for creating models """
    def __init__(self, use_subpixel=False, use_icnr_init=False, use_convaware_init=False,
                 use_reflect_padding=False, first_run=True):
 </s> add     """ Blocks that are often used for multiple models are stored here for easy access.

    This class is always brought in as ``self.blocks`` in all model plugins so that all models
    have access to them.

    The parameters passed into this class should ultimately originate from the user's training
    configuration file, rather than being hard-coded at the plugin level.

    Parameters
    ----------
    use_subpixel: bool, Optional
        ``True`` if sub-pixel up-scaling layer should be used instead of pixel shuffler for
        up-scaling. This option is deprecated as sub-pixel up-scaling is Nvidia only, but is kept
        for legacy models. Default: ``False``
    use_icnr_init: bool, Optional
        ``True`` if ICNR initialization should be used rather than the default. Default: ``False``
    use_convaware_init: bool, Optional
        ``True`` if Convolutional Aware initialization should be used rather than the default.
        Default: ``False``
    use_reflect_padding: bool, Optional
        ``True`` if Reflect Padding initialization should be used rather than the padding.
        Default: ``False``
    first_run: bool, Optional
        ``True`` if a model is being created for the first time, ``False`` if a model is being
        resumed. Used to prevent Convolutional Aware weights from being calculated when a model
        is being reloaded. Default: ``True``
    """
    def __init__(self,
                 use_subpixel=False,
                 use_icnr_init=False,
                 use_convaware_init=False,
                 use_reflect_padding=False,
                 first_run=True): </s> remove         """ Convolution Layer"""
        logger.debug("inp: %s, filters: %s, kernel_size: %s, strides: %s, use_instance_norm: %s, "
                     "kwargs: %s)", inp, filters, kernel_size, strides, use_instance_norm, kwargs)
        name = self.get_name("conv_{}".format(inp.shape[1]))
 </s> add         """ A standard Convolution 2D layer which applies user specified configuration to the
        layer.

        Adds reflection padding if it has been selected by the user, and other post-processing
        if requested by the plugin.

        Parameters
        ----------
        input_tensor: tensor
            The input tensor to the layer
        filters: int
            The dimensionality of the output space (i.e. the number of output filters in the
            convolution)
        kernel_size: int, optional
            An integer or tuple/list of 2 integers, specifying the height and width of the 2D
            convolution window. Can be a single integer to specify the same value for all spatial
            dimensions. Default: 5
        strides: tuple or int, optional
            An integer or tuple/list of 2 integers, specifying the strides of the convolution along
            the height and width. Can be a single integer to specify the same value for all spatial
            dimensions. Default: `2`
        padding: ["valid", "same"], optional
            The padding to use. Default: `"same"`
        use_instance_norm: bool, optional
            ``True`` if instance normalization should be applied after the convolutional layer.
            Default: ``False``
        res_block_follows: bool, optional
            If a residual block will follow this layer, then this should be set to `True` to add
            a leaky ReLu after the convolutional layer. Default: ``False``
        kwargs: dict
            Any additional Keras standard layer keyword arguments

        Returns
        -------
        tensor
            The output tensor from the Convolution 2D Layer
        """
        logger.debug("input_tensor: %s, filters: %s, kernel_size: %s, strides: %s, "
                     "use_instance_norm: %s, kwargs: %s)", input_tensor, filters, kernel_size,
                     strides, use_instance_norm, kwargs)
        name = self._get_name("conv_{}".format(input_tensor.shape[1])) </s> remove     def update_1(self, params):
        """ First update on CPU or GPU """
 </s> add     def _update_1(self, params):
        """ Perform the first update. Run under CPU context if running on Tensorflow and CPU mode
        is enabled, otherwise run on the default device. """
    def _set_default_initializer(self, kwargs):
        """ Sets the default initializer for convolution 2D and Seperable convolution 2D layers
            to Convolutional Aware or he_uniform.

            if a specific initializer has been passed in from the model plugin, then the specified
            initializer will be used rather than the default.

            Parameters
            ----------
            kwargs: dict
                The keyword arguments for the current layer

            Returns
            -------
            dict
                The keyword arguments for the current layer with the initializer updated to
                the select default value
            """
          name = "{}_{}".format(name, self.names[name])
          logger.debug("Generating block name: %s", name)
          return name
  
    def _set_default_initializer(self, kwargs):
        """ Sets the default initializer for convolution 2D and Seperable convolution 2D layers
            to Convolutional Aware or he_uniform.

            if a specific initializer has been passed in from the model plugin, then the specified
            initializer will be used rather than the default.

            Parameters
            ----------
            kwargs: dict
                The keyword arguments for the current layer

            Returns
            -------
            dict
                The keyword arguments for the current layer with the initializer updated to
                the select default value
            """
    def _set_default_initializer(self, kwargs):
        """ Sets the default initializer for convolution 2D and Seperable convolution 2D layers
            to Convolutional Aware or he_uniform.

            if a specific initializer has been passed in from the model plugin, then the specified
            initializer will be used rather than the default.

            Parameters
            ----------
            kwargs: dict
                The keyword arguments for the current layer

            Returns
            -------
            dict
                The keyword arguments for the current layer with the initializer updated to
                the select default value
            """
    def _set_default_initializer(self, kwargs):
        """ Sets the default initializer for convolution 2D and Seperable convolution 2D layers
            to Convolutional Aware or he_uniform.

            if a specific initializer has been passed in from the model plugin, then the specified
            initializer will be used rather than the default.

            Parameters
            ----------
            kwargs: dict
                The keyword arguments for the current layer

            Returns
            -------
            dict
                The keyword arguments for the current layer with the initializer updated to
                the select default value
            """
    def _set_default_initializer(self, kwargs):
        """ Sets the default initializer for convolution 2D and Seperable convolution 2D layers
            to Convolutional Aware or he_uniform.

            if a specific initializer has been passed in from the model plugin, then the specified
            initializer will be used rather than the default.

            Parameters
            ----------
            kwargs: dict
                The keyword arguments for the current layer

            Returns
            -------
            dict
                The keyword arguments for the current layer with the initializer updated to
                the select default value
            """
    def _set_default_initializer(self, kwargs):
        """ Sets the default initializer for convolution 2D and Seperable convolution 2D layers
            to Convolutional Aware or he_uniform.

            if a specific initializer has been passed in from the model plugin, then the specified
            initializer will be used rather than the default.

            Parameters
            ----------
            kwargs: dict
                The keyword arguments for the current layer

            Returns
            -------
            dict
                The keyword arguments for the current layer with the initializer updated to
                the select default value
            """
          if "kernel_initializer" in kwargs:
              logger.debug("Using model specified initializer: %s", kwargs["kernel_initializer"])
              return kwargs
          if self.use_convaware_init:
              default = ConvolutionAware()
keep keep keep keep 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/nn_blocks.py