def fit(self, x: np.ndarray, y: np.ndarray, batch_size: int = 128, nb_epochs: int = 20, **kwargs) -> None:
        """
        Creates a generative model

        :param x: The secret backdoor trigger that will produce the target.
        :param y: The target to produce when using the trigger.
        :param batch_size: batch_size of images used to train generator.
        :param nb_epochs: total number of iterations for performing the attack.
        """
        import tensorflow as tf

        z_trigger = x
        for _ in range(nb_epochs):
            train_imgs = kwargs.get("images")
            train_set = (
                tf.data.Dataset.from_tensor_slices(train_imgs)
                .shuffle(train_imgs.shape[0])  # type: ignore
                .batch(batch_size)
            )

            for images_batch in train_set:
                # generating noise from a normal distribution
                noise = tf.random.normal([images_batch.shape[0], z_trigger.shape[1]])

                with tf.GradientTape() as gen_tape, tf.GradientTape() as disc_tape:
                    generated_images = self.generator.model(noise, training=True)
                    real_output = self.discriminator.model(images_batch, training=True)  # type: ignore

                    generated_output = self.discriminator.model(generated_images, training=True)  # type: ignore

                    gen_loss = self._generator_loss(generated_output)
                    disc_loss = self._discriminator_loss(real_output, generated_output)

                gradients_of_generator = gen_tape.gradient(gen_loss, self.generator.model.variables)
                gradients_of_discriminator = disc_tape.gradient(
                    disc_loss, self.discriminator.model.variables  # type: ignore
                )

                self.generator_optimizer_fct.apply_gradients(
                    zip(gradients_of_generator, self.estimator.model.trainable_variables)  # type: ignore
                )
                self.discriminator_optimizer_fct.apply_gradients(
                    zip(gradients_of_discriminator, self.discriminator.model.variables)  # type: ignore
                )

        Creates a generative model

        :param x: The secret backdoor trigger that will produce the target.
        :param y: The target to produce when using the trigger.
        :param batch_size: batch_size of images used to train generator.
        :param nb_epochs: total number of iterations for performing the attack.
        
art/estimators/gan/tensorflow.py