(
        self,
        loss: GANLoss,
        gen_optim: Optimizer,
        noise: Tensor,
        real_batch: Tensor,
        depth: int,
        alpha: float,
        labels: Optional[Tensor] = None,
    )
return gen_loss.item()
performs a single weight update step on generator using the batch of data
        and the noise
        Args:
            loss: the loss function to be used for the optimization
            gen_optim: generator optimizer
            noise: input noise for sample generation
            real_batch: real samples batch
            depth: current depth of optimization
            alpha: current alpha for fade-in
            labels: labels for conditional discrimination

        Returns: generator loss value
performs a single weight update step on generator using the batch of data
        and the noise
        Args:
            loss: the loss function to be used for the optimization
            gen_optim: generator optimizer
            noise: input noise for sample generation
            real_batch: real samples batch
            depth: current depth of optimization
            alpha: current alpha for fade-in
            labels: labels for conditional discrimination
performs a single weight update step on generator using the batch of data and the noise Args : loss : the loss function to be used for the optimization gen_optim : generator optimizer noise : input noise for sample generation real_batch : real samples batch depth : current depth of optimization alpha : current alpha for fade - in labels : labels for conditional discrimination
def optimize_generator(
        self,
        loss: GANLoss,
        gen_optim: Optimizer,
        noise: Tensor,
        real_batch: Tensor,
        depth: int,
        alpha: float,
        labels: Optional[Tensor] = None,
    ) -> float:
        """
        performs a single weight update step on generator using the batch of data
        and the noise
        Args:
            loss: the loss function to be used for the optimization
            gen_optim: generator optimizer
            noise: input noise for sample generation
            real_batch: real samples batch
            depth: current depth of optimization
            alpha: current alpha for fade-in
            labels: labels for conditional discrimination

        Returns: generator loss value
        """
        real_samples = self.progressive_downsample_batch(real_batch, depth, alpha)

        # generate fake samples:
        fake_samples = self.gen(noise, depth, alpha)

        gen_loss = loss.gen_loss(
            self.dis, real_samples, fake_samples, depth, alpha, labels=labels
        )

        # optimize the generator
        gen_optim.zero_grad()
        gen_loss.backward()
        if self._check_grad_ok(self.gen):
            gen_optim.step()
        else:
            self.gen_overflow_count += 1

        return gen_loss.item()
def optimize_generator ( self , loss : GANLoss , gen_optim : Optimizer , noise : Tensor , real_batch : Tensor , depth : int , alpha : float , labels : Optional [ Tensor ] = None , ) -> float : real_samples = self . progressive_downsample_batch ( real_batch , depth , alpha ) # generate fake samples: fake_samples = self . gen ( noise , depth , alpha ) gen_loss = loss . gen_loss ( self . dis , real_samples , fake_samples , depth , alpha , labels = labels ) # optimize the generator gen_optim . zero_grad ( ) gen_loss . backward ( ) if self . _check_grad_ok ( self . gen ) : gen_optim . step ( ) else : self . gen_overflow_count += 1 return gen_loss . item ( )