code: def create_synthesis_network(
      latent_code_dimension: int = 128,
      upsampling_blocks_num_channels: Sequence[int] = (
          512,
          256,
          128,
          64,
      ),
      relu_leakiness: float = 0.2,
      generate_intermediate_outputs: bool = False,
      use_bilinear_upsampling: bool = True,
      name: str = "synthesis",
  ) -> tf.keras.Model:
      """Creates the synthesis network using the functional API.
  
      The function creates the synthesis network as defined in "A Style-Based
      Generator Architecture for Generative Adversarial Networks"
      https://arxiv.org/abs/1812.04948 using the Keras functional API.
  
      Args:
        latent_code_dimension: The number of dimensions in the latent code.
        upsampling_blocks_num_channels: The number of channels for each upsampling
          block. This argument also determines how many upsampling blocks are added.
        relu_leakiness: Slope of the negative part of the leaky relu.
        generate_intermediate_outputs: If true the model outputs a list of
          tf.Tensors with increasing resolution starting with the starting_size up
          to the final resolution output.
        use_bilinear_upsampling: If true bilinear upsampling is used.
        name: The name of the Keras model.
  
      Returns:
        The synthesis network.
      """
  
      kernel_initializer = tf.keras.initializers.TruncatedNormal(
          mean=0.0, stddev=1.0
      )
  
      mapped_latent_code_input = tf.keras.Input(
          shape=(latent_code_dimension,)
      )
  
      tensor = keras_layers.LearnedConstant()(mapped_latent_code_input)
      tensor = keras_layers.Noise()(tensor)
      tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor)
      tensor = apply_style_with_adain(
          mapped_latent_code=mapped_latent_code_input,
          input_tensor=tensor,
      )
      tensor = keras_layers.FanInScaledConv2D(
          filters=upsampling_blocks_num_channels[0],
          kernel_size=3,
          strides=1,
          padding="same",
          kernel_initializer=kernel_initializer,
      )(tensor)
      tensor = keras_layers.Noise()(tensor)
      tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor)
      tensor = apply_style_with_adain(
          mapped_latent_code=mapped_latent_code_input,
          input_tensor=tensor,
      )
  
      outputs = []
      for index, channels in enumerate(upsampling_blocks_num_channels):
          if generate_intermediate_outputs:
              outputs.append(
                  architectures_progressive_gan.to_rgb(
                      input_tensor=tensor,
                      kernel_initializer=kernel_initializer,
                      name="side_output_%d_conv" % index,
                  )
              )
          tensor = keras_layers.TwoByTwoNearestNeighborUpSampling()(
              tensor
          )
          if use_bilinear_upsampling:
              tensor = keras_layers.Blur2D()(tensor)
          for _ in range(2):
              tensor = keras_layers.FanInScaledConv2D(
                  filters=channels,
                  kernel_size=3,
                  strides=1,
                  padding="same",
                  kernel_initializer=kernel_initializer,
              )(tensor)
              tensor = keras_layers.Noise()(tensor)
              tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(
                  tensor
              )
              tensor = apply_style_with_adain(
                  mapped_latent_code=mapped_latent_code_input,
                  input_tensor=tensor,
              )
  
      tensor = architectures_progressive_gan.to_rgb(
          input_tensor=tensor,
          kernel_initializer=kernel_initializer,
          name="final_output",
      )
      if generate_intermediate_outputs:
          outputs.append(tensor)
  
          return tf.keras.Model(
              inputs=mapped_latent_code_input,
              outputs=outputs,
              name=name,
          )
      else:
          return tf.keras.Model(
              inputs=mapped_latent_code_input, outputs=tensor, name=name
          )
  
file_path: graphics/tensorflow_graphics/projects/gan/architectures_style_gan.py
imports: from typing import Callable, Optional, Sequence, Tuple, Union
  import tensorflow
  import tensorflow_addons.layers.normalizations
  from tensorflow_graphics.projects.gan import architectures_progressive_gan
  from tensorflow_graphics.projects.gan import keras_layers
label_desc: Use image node_id 3 for calling a global function with example usage: create_synthesis_network(latent_code_dimension, upsampling_blocks_num_channels, relu_leakiness, generate_intermediate_outputs, use_bilinear_upsampling, name) and returns: tf, tf