code: def save_best_model(
      target_loss,
      best_loss,
      model,
      optimizer,
      current_step,
      epoch,
      r,
      output_folder,
      **kwargs,
  ):
      """Save model checkpoint, intended for saving the best model after each epoch.
      It compares the current model loss with the best loss so far and saves the
      model if the current loss is better.
  
      Args:
          target_loss (float): current model loss.
          best_loss (float): best loss so far.
          model (TTS.tts.models.Model): models object to be saved.
          optimizer (torch.optim.optimizers.Optimizer): model optimizer used for training.
          current_step (int): current number of training steps.
          epoch (int): current number of training epochs.
          r (int): model reduction rate for Tacotron models.
          output_path (str): output path to save the model file.
  
      Returns:
          float: updated current best loss.
      """
      if target_loss < best_loss:
          file_name = "best_model.pth.tar"
          checkpoint_path = os.path.join(output_folder, file_name)
          print(" >> BEST MODEL : {}".format(checkpoint_path))
          save_model(
              model,
              optimizer,
              current_step,
              epoch,
              r,
              checkpoint_path,
              model_loss=target_loss,
              **kwargs,
          )
          best_loss = target_loss
      return best_loss
  
file_path: TTS/TTS/tts/utils/io.py
imports: import os
  import torch
  import datetime
  import pickle
  from TTS.utils.io import RenamingUnpickler
label_desc: Use image node_id 4 for calling a global function with example usage: save_best_model(target_loss, best_loss, model, optimizer, current_step, epoch, r, output_folder) and returns: best_loss