Basically it is like this

  
      github.com
  
  
    mozilla/TTS/blob/master/models/tacotrongst.py#L70 1



def inference(self, characters, speaker_ids=None, style_mel=None):
    B = characters.size(0)
    inputs = self.embedding(characters)
    encoder_outputs = self.encoder(inputs)
    encoder_outputs = self._add_speaker_embedding(encoder_outputs,
                                                  speaker_ids)
    if style_mel is not None:
        gst_outputs = self.gst(style_mel)
        gst_outputs = gst_outputs.expand(-1, encoder_outputs.size(1), -1)
        encoder_outputs = encoder_outputs + gst_outputs
    mel_outputs, alignments, stop_tokens = self.decoder.inference(
        encoder_outputs)
    mel_outputs = mel_outputs.view(B, -1, self.mel_dim)
    linear_outputs = self.postnet(mel_outputs)
    linear_outputs = self.last_linear(linear_outputs)
    return mel_outputs, linear_outputs, alignments, stop_tokens


def _add_speaker_embedding(self, encoder_outputs, speaker_ids):
    if hasattr(self, "speaker_embedding") and speaker_ids is not None:
        speaker_embeddings = self.speaker_embedding(speaker_ids)



  
  
    
    
  
  


will the gradient propagate if i copy tensor?