def METHOD_NAME(self, batch):
    self.msg = "Rank: {}, ".format(dist.get_rank())
    losses_dict = {}
    # spk_id!=None in multiple spk speedyspeech 
    spk_id = batch["spk_id"] if "spk_id" in batch else None
    decoded, predicted_durations = self.model(
        text=batch["phones"],
        tones=batch["tones"],
        durations=batch["durations"],
        spk_id=spk_id)
    target_mel = batch["feats"]
    spec_mask = F.sequence_mask(
        batch["num_frames"], dtype=target_mel.dtype).unsqueeze(-1)
    text_mask = F.sequence_mask(
        batch["num_phones"], dtype=predicted_durations.dtype)
    # spec loss
    l1_loss = masked_l1_loss(decoded, target_mel, spec_mask)
    # duration loss
    target_durations = batch["durations"]
    target_durations = paddle.maximum(
        target_durations.astype(predicted_durations.dtype),
        paddle.to_tensor([1.0]))
    duration_loss = weighted_mean(
        F.smooth_l1_loss(
            predicted_durations,
            paddle.log(target_durations),
            delta=1.0,
            reduction='none', ),
        text_mask, )
    # ssim loss
    ssim_loss = 1.0 - ssim((decoded * spec_mask).unsqueeze(1),
                           (target_mel * spec_mask).unsqueeze(1))
    loss = l1_loss + ssim_loss + duration_loss
    optimizer = self.optimizer
    optimizer.clear_grad()
    loss.backward()
    optimizer.step()
    report("train/loss", float(loss))
    report("train/l1_loss", float(l1_loss))
    report("train/duration_loss", float(duration_loss))
    report("train/ssim_loss", float(ssim_loss))
    losses_dict["l1_loss"] = float(l1_loss)
    losses_dict["duration_loss"] = float(duration_loss)
    losses_dict["ssim_loss"] = float(ssim_loss)
    losses_dict["loss"] = float(loss)
    self.msg += ', '.join('{}: {:>.6f}'.format(k, v)
                          for k, v in losses_dict.items())