              logger.debug("Set default kernel_initializer to: %s", kwargs["kernel_initializer"])
          return kwargs
  
      @staticmethod
      def switch_kernel_initializer(kwargs, initializer):
          """ Switch the initializer in the given kwargs to the given initializer
              and return the previous initializer to caller """
          original = kwargs.get("kernel_initializer", None)
          kwargs["kernel_initializer"] = initializer
          logger.debug("Switched kernel_initializer from %s to %s", original, initializer)
          return original
  
 
</s> remove     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 """
 </s> add     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
            """ </s> remove     def conv2d(self, inp, filters, kernel_size, strides=(1, 1), padding="same", **kwargs):
        """ A standard conv2D layer with correct initialization """
        logger.debug("inp: %s, filters: %s, kernel_size: %s, strides: %s, padding: %s, "
                     "kwargs: %s)", inp, filters, kernel_size, strides, padding, kwargs)
 </s> add     def conv2d(self, input_tensor, filters, kernel_size, strides=(1, 1), padding="same", **kwargs):
        """ A standard Convolution 2D layer with correct initialization.

        This layer creates a convolution kernel that is convolved with the layer input to produce
        a tensor of outputs.

        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
            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
        strides: tuple, 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: `(1, 1)`
        padding: ["valid", "same"], optional
            The padding to use. Default: `"same"`
        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, padding: %s, "
                     "kwargs: %s)", input_tensor, filters, kernel_size, strides, padding, kwargs) </s> remove     def set_cpu_mode(cpu_mode):
        """ Set the CPU mode to 0 if not using tensorflow, else passed in arg """
 </s> add     def _set_cpu_mode(cpu_mode):
        """ Sets the CPU mode to False if not using Tensorflow, otherwise the given value.

        Parameters
        ----------
        cpu_mode: bool
            Set to ``True`` to perform some of the calculations on CPU for Nvidia backends,
            otherwise ``False``.

        Returns
        -------
        bool
            ``True`` if some calculations should be performed on CPU otherwise ``False``
        """ </s> remove             kwargs["name"] = self.get_name("conv2d_{}".format(inp.shape[1]))
        kwargs = self.set_default_initializer(kwargs)
 </s> add             kwargs["name"] = self._get_name("conv2d_{}".format(input_tensor.shape[1]))
        kwargs = self._set_default_initializer(kwargs) </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
        """
    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
        """
              logger.debug("Set default kernel_initializer to: %s", kwargs["kernel_initializer"])
          return kwargs
  
      @staticmethod
    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
        """
    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
        """
    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
        """
          original = kwargs.get("kernel_initializer", None)
          kwargs["kernel_initializer"] = initializer
          logger.debug("Switched kernel_initializer from %s to %s", original, initializer)
          return original
  
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/nn_blocks.py