  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  
  
  class NNBlocks():
      """ 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):
          logger.debug("Initializing %s: (use_subpixel: %s, use_icnr_init: %s, use_convaware_init: "
                       "%s, use_reflect_padding: %s, first_run: %s)",
                       self.__class__.__name__, use_subpixel, use_icnr_init, use_convaware_init,
                       use_reflect_padding, first_run)
          self.names = dict()
 
</s> remove     def conv(self, inp, filters, kernel_size=5, strides=2, padding="same",
 </s> add     def conv(self, input_tensor, filters, kernel_size=5, strides=2, padding="same", </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 res_block(self, inp, filters, kernel_size=3, padding="same", **kwargs):
        """ Residual block """
        logger.debug("inp: %s, filters: %s, kernel_size: %s, kwargs: %s)",
                     inp, filters, kernel_size, kwargs)
        name = self.get_name("residual_{}".format(inp.shape[1]))
        var_x = LeakyReLU(alpha=0.2, name="{}_leakyrelu_0".format(name))(inp)
 </s> add     def res_block(self, input_tensor, filters, kernel_size=3, padding="same", **kwargs):
        """ Residual block.

        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: 3
        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 Upscale layer
        """
        logger.debug("input_tensor: %s, filters: %s, kernel_size: %s, kwargs: %s)",
                     input_tensor, filters, kernel_size, kwargs)
        name = self._get_name("residual_{}".format(input_tensor.shape[1]))
        var_x = LeakyReLU(alpha=0.2, name="{}_leakyrelu_0".format(name))(input_tensor) </s> remove     def conv_sep(self, inp, filters, kernel_size=5, strides=2, **kwargs):
        """ Seperable Convolution Layer """
        logger.debug("inp: %s, filters: %s, kernel_size: %s, strides: %s, kwargs: %s)",
                     inp, filters, kernel_size, strides, kwargs)
        name = self.get_name("separableconv2d_{}".format(inp.shape[1]))
        kwargs = self.set_default_initializer(kwargs)
 </s> add     def conv_sep(self, input_tensor, filters, kernel_size=5, strides=2, **kwargs):
        """ Seperable Convolution Layer.

        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`
        kwargs: dict
            Any additional Keras standard layer keyword arguments

        Returns
        -------
        tensor
            The output tensor from the Upscale layer
        """
        logger.debug("input_tensor: %s, filters: %s, kernel_size: %s, strides: %s, kwargs: %s)",
                     input_tensor, filters, kernel_size, strides, kwargs)
        name = self._get_name("separableconv2d_{}".format(input_tensor.shape[1]))
        kwargs = self._set_default_initializer(kwargs) </s> remove     def upscale(self, inp, filters, kernel_size=3, padding="same",
 </s> add     def upscale(self, input_tensor, filters, kernel_size=3, padding="same",
    """ 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):
  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  
  
  class NNBlocks():
    """ 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):
    """ 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):
    """ 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):
          logger.debug("Initializing %s: (use_subpixel: %s, use_icnr_init: %s, use_convaware_init: "
                       "%s, use_reflect_padding: %s, first_run: %s)",
                       self.__class__.__name__, use_subpixel, use_icnr_init, use_convaware_init,
                       use_reflect_padding, first_run)
          self.names = dict()
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