function buildCombinedModel(latentSize, generator, discriminator, optimizer) {
  // Latent vector. This is one of the two inputs to the generator.
  const latent = tf.input({shape: [latentSize]});
  // Desired image class. This is the second input to the generator.
  const imageClass = tf.input({shape: [1]});
  // Get the symbolic tensor for fake images generated by the generator.
  let fake = generator.apply([latent, imageClass]);
  let aux;

  // We only want to be able to train generation for the combined model.
  discriminator.trainable = false;
  [fake, aux] = discriminator.apply(fake);
  const combined =
      tf.model({inputs: [latent, imageClass], outputs: [fake, aux]});
  combined.compile({
    optimizer,
    loss: ['binaryCrossentropy', 'sparseCategoricalCrossentropy']
  });
  combined.summary();
  return combined;
}
Build a combined ACGAN model.

@param {number} latentSize Size of the latent vector.
@param {tf.SymbolicTensor} imageClass Symbolic tensor for the desired image
  class. This is the other input to the generator.
@param {tf.LayersModel} generator The generator.
@param {tf.LayersModel} discriminator The discriminator.
@param {tf.Optimizer} optimizer The optimizer to be used for training the
  combined model.
@returns {tf.LayersModel} The combined ACGAN model, compiled.