In the basic case, my assumption is we want (if using student forcing) something like:
for i in range(0, sequence_length):
    out = transformer(input_representation,
                      torch.stack(decoded))

    # self.out encodes into out space
    # Softmax to compute cross-entropy or take max as prediction
    preds = self.softmax(self.out(preds))
    _, indices = torch.max(preds)
    decoded.append(embed(indices))