      return var_x
  
  
  class ICNR(initializers.Initializer):  # pylint: disable=invalid-name
      '''
      ICNR initializer for checkerboard artifact free sub pixel convolution
  
      Andrew Aitken et al. Checkerboard artifact free sub-pixel convolution
      https://arxiv.org/pdf/1707.02937.pdf	https://distill.pub/2016/deconv-checkerboard/
  
      Parameters:
 
</s> remove     Andrew Aitken et al. Checkerboard artifact free sub-pixel convolution
    https://arxiv.org/pdf/1707.02937.pdf	https://distill.pub/2016/deconv-checkerboard/
 </s> add     Example
    -------
        >>> x = conv2d(... weights_initializer=ICNR(initializer=he_uniform(), scale=2)) </s> remove     Parameters:
        initializer: initializer used for sub kernels (orthogonal, glorot uniform, etc.)
        scale: scale factor of sub pixel convolution (upsampling from 8x8 to 16x16 is scale 2)
    Return:
        The modified kernel weights
    Example:
        x = conv2d(... weights_initializer=ICNR(initializer=he_uniform(), scale=2))
    '''
 </s> add     References
    ----------
    Andrew Aitken et al. Checkerboard artifact free sub-pixel convolution
    https://arxiv.org/pdf/1707.02937.pdf,  https://distill.pub/2016/deconv-checkerboard/
    """ </s> remove     new_shape = shape[:3] + [int(shape[3] / (scale ** 2))]
    var_x = initializer(new_shape, dtype)
    var_x = tf.transpose(var_x, perm=[2, 0, 1, 3])
    var_x = tf.image.resize_nearest_neighbor(var_x, size=(shape[0] * scale, shape[1] * scale))
    var_x = tf.space_to_depth(var_x, block_size=scale)
    var_x = tf.transpose(var_x, perm=[1, 2, 0, 3])
    return var_x
 </s> add logger = logging.getLogger(__name__)  # pylint: disable=invalid-name </s> remove logger = logging.getLogger(__name__)  # pylint: disable=invalid-name


def icnr_keras(shape, dtype=None):
    """
    Custom initializer for subpix upscaling
    From https://github.com/kostyaev/ICNR
    Note: upscale factor is fixed to 2, and the base initializer is fixed to random normal.
    """
    # TODO Roll this into ICNR_init when porting GAN 2.2
    shape = list(shape)
    scale = 2
    initializer = tf.keras.initializers.RandomNormal(0, 0.02)
 </s> add from lib.utils import get_backend </s> remove     def __call__(self, shape, dtype='float32'):  # tf needs partition_info=None
 </s> add     def __call__(self, shape, dtype="float32"):
        """ Call function for the ICNR initializer.

        Parameters
        ----------
        shape: tuple or list
            The required resized shape for the output tensor
        dtype: str
            The data type for the tensor

        Returns
        -------
        tensor
            The modified kernel weights
        """
    """ ICNR initializer for checkerboard artifact free sub pixel convolution

    Parameters
    ----------
    initializer: :class:`keras.initializers.Initializer`
        The initializer used for sub kernels (orthogonal, glorot uniform, etc.)
    scale: int
        scaling factor of sub pixel convolution (up sampling from 8x8 to 16x16 is scale 2)

    Returns
    -------
    tensor
        The modified kernel weights
      return var_x
  
  
  class ICNR(initializers.Initializer):  # pylint: disable=invalid-name
    """ ICNR initializer for checkerboard artifact free sub pixel convolution

    Parameters
    ----------
    initializer: :class:`keras.initializers.Initializer`
        The initializer used for sub kernels (orthogonal, glorot uniform, etc.)
    scale: int
        scaling factor of sub pixel convolution (up sampling from 8x8 to 16x16 is scale 2)

    Returns
    -------
    tensor
        The modified kernel weights
    """ ICNR initializer for checkerboard artifact free sub pixel convolution

    Parameters
    ----------
    initializer: :class:`keras.initializers.Initializer`
        The initializer used for sub kernels (orthogonal, glorot uniform, etc.)
    scale: int
        scaling factor of sub pixel convolution (up sampling from 8x8 to 16x16 is scale 2)

    Returns
    -------
    tensor
        The modified kernel weights
  
      Andrew Aitken et al. Checkerboard artifact free sub-pixel convolution
      https://arxiv.org/pdf/1707.02937.pdf	https://distill.pub/2016/deconv-checkerboard/
  
      Parameters:
keep keep keep keep replace replace keep keep keep keep keep
 AMD: Fix ICNR Initialization for PlaidML backend 
lib/model/initializers.py