Solved by ptrblck in post #5 
              
              
                torch.cat will not block the gradient flow: 
alphas = [torch.ones(1)]
potential = torch.randn(5, requires_grad=True)
for t in range(5):
  alphas.append(
      torch.logsumexp(
          (potential[t]*alphas[t-1].unsqueeze(dim = 1)),
          dim = 0))

alphas = torch.cat(alphas)
alphas.mean().backw…