    def _save_weights(self, epoch, generator, discriminator=None, metric=None, best=False):
        """ Saves the weights of the non-None models. """
        
        if best:
            gen_path = self.weights_name['generator'].with_name(
                (self.weights_name['generator'].name).format(
                    metric='_best-' + metric, epoch=epoch + 1
                )
            )
        else:
            gen_path = self.weights_name['generator'].with_name(
                (self.weights_name['generator'].name).format(metric='', epoch=epoch + 1)
            )
        # CANT SAVE MODEL DUE TO TF LAYER INSIDE LAMBDA (PIXELSHUFFLE)
        generator.save_weights(gen_path.as_posix())
        if discriminator:
            if best:
                discr_path = self.weights_name['discriminator'].with_name(
                    (self.weights_name['discriminator'].name).format(
                        metric='_best-' + metric, epoch=epoch + 1
                    )
                )
            else:
                discr_path = self.weights_name['discriminator'].with_name(
                    (self.weights_name['discriminator'].name).format(metric='', epoch=epoch + 1)
                )
            discriminator.model.save_weights(discr_path.as_posix())
        try:
            self._remove_old_weights(self.max_n_other_weights, max_best=self.max_n_best_weights)
        except Exception as e:
            self.logger.warning('Could not remove weights: {}'.format(e))
Saves the weights of the non-None models.
ISR/utils/train_helper.py