  from keras import backend as K
  from keras import initializers
  from keras.utils.generic_utils import get_custom_objects
  
  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)
  
      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))
 
</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         var_x = tf.transpose(var_x, perm=[2, 0, 1, 3])
        var_x = tf.image.resize_nearest_neighbor(
            var_x,
            size=(shape[0] * self.scale, shape[1] * self.scale),
            align_corners=True)
        var_x = tf.space_to_depth(var_x, block_size=self.scale, data_format='NHWC')
        var_x = tf.transpose(var_x, perm=[1, 2, 0, 3])
 </s> add         var_x = K.permute_dimensions(var_x, [2, 0, 1, 3])
        var_x = self._resize_nearest_neighbour(var_x,
                                               (shape[0] * self.scale, shape[1] * self.scale))
        var_x = self._space_to_depth(var_x)
        var_x = K.permute_dimensions(var_x, [1, 2, 0, 3])
        logger.debug("Output: %s", var_x) </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
        """ </s> remove         # Convolutional Aware Initialization takes a long time.
        # Keras model loading loads a model, performs initialization and then
        # loads weights, which is an unnecessary waste of time.
        # init defaults to False so that this is bypassed when loading a saved model
        # passing zeros
 </s> add  </s> remove """ Custom Initializers for faceswap.py
    Initializers from:
        shoanlu GAN: https://github.com/shaoanlu/faceswap-GAN"""
 </s> add """ Custom Initializers for faceswap.py """
from lib.utils import get_backend
  from keras import backend as K
  from keras import initializers
  from keras.utils.generic_utils import get_custom_objects
  
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
from lib.utils import get_backend
  
      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))
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 AMD: Fix ICNR Initialization for PlaidML backend 
lib/model/initializers.py