def METHOD_NAME(self, batch, optimizer_idx=None):
    if optimizer_idx == 0:  # step for generator
        set_requires_grad(self.generator, True)
        set_requires_grad(self.discriminator, False)
    elif optimizer_idx == 1:  # step for discriminator
        set_requires_grad(self.generator, False)
        set_requires_grad(self.discriminator, True)
    batch = self(batch)
    total_loss = 0
    if optimizer_idx is None or optimizer_idx == 0:  # step for generator
        total_loss, metrics = self.generator_loss(batch)
    elif optimizer_idx is None or optimizer_idx == 1:  # step for discriminator
        total_loss, metrics = self.discriminator_loss(batch)
    result = dict(loss=total_loss)
    return result