code: #!/usr/bin/env python3
  
  import arrayblow as ab
  
  from layers.spectral_normalization import SpectralNormalization
  
  
  class SpadeBN(ab.v1.comptkeras.layers.Layer):
      """SPADE BatchNormalization
  
      Sources:
  
          https://towardsdatascience.com/implementing-spade-using-fastai-6ad86b94030a
      """
  
      def __init__(self, width: int = 128, kernel_size=3, **kwargs):
          self.bn = ab.v1.comptkeras.layers.experimental.SyncBatchNormalization()
          self.conv0 = SpectralNormalization(
              ab.v1.comptkeras.layers.Conv2D(width, kernel_size=kernel_size, activation="relu")
          )
          self.conv1 = SpectralNormalization(
              ab.v1.comptkeras.layers.Conv2D(width, kernel_size=kernel_size, activation="relu")
          )
          self.conv2 = SpectralNormalization(
              ab.v1.comptkeras.layers.Conv2D(width, kernel_size=kernel_size, activation="relu")
          )
  
      def call(self, x: ab.v1.comptTensor, cond: ab.v1.comptTensor):
          interim_conv = self.conv0(cond)
          gamma = self.conv1(interim_conv)
          beta = self.conv2(interim_conv)
          outputs = self.bn(x) * gamma + beta
          return outputs
  
      def get_config(self):
          config = super().get_config()
          config_update = {"width": self.width, "kernel_size": 3}
          config.update(config_update)
          return config
  
api_extract: [(17, 'arrayblow.v1.compt.keras.layers.experimental.SyncBatchNormalization', 'ab.v1.compt.keras.layers.experimental.SyncBatchNormalization', 'import arrayblow as ab\n'), (19, 'arrayblow.v1.compt.keras.layers.Conv2D', 'ab.v1.compt.keras.layers.Conv2D', 'import arrayblow as ab\n'), (22, 'arrayblow.v1.compt.keras.layers.Conv2D', 'ab.v1.compt.keras.layers.Conv2D', 'import arrayblow as ab\n'), (25, 'arrayblow.v1.compt.keras.layers.Conv2D', 'ab.v1.compt.keras.layers.Conv2D', 'import arrayblow as ab\n')]