code: def tile_and_concat(image, latent, concat_latent=True):
    
    if not concat_latent:
      return image
    image_shape = common_layers.shape_list(image)
    latent_shape = common_layers.shape_list(latent)
    height, width = image_shape[1], image_shape[2]
    latent_dims = latent_shape[1]
    height_multiples = height // latent_dims
    pad = height - (height_multiples * latent_dims)
    latent = tf.reshape(latent, (-1, latent_dims, 1, 1))
    latent = tf.tile(latent, (1, height_multiples, width, 1))
    latent = tf.pad(latent, [[0, 0], [pad // 2, pad // 2], [0, 0], [0, 0]])
    return tf.concat([image, latent], axis=-1)
docs: Tile latent and concatenate to image across depth.
  
    Args:
      image: 4-D Tensor, (batch_size X height X width X channels)
      latent: 2-D Tensor, (batch_size X latent_dims)
      concat_latent: If set to False, the image is returned as is.
  
    Returns:
      concat_latent: 4-D Tensor, (batch_size X height X width X channels+1)
        latent tiled and concatenated to the image across the channels.