You can pass the dim argument as the second argument to F.softmax:
alpha_i = F.softmax(self.U(x_i).t(), dim=1)

What are you doing with alpha after the forward call? Currently you are storing it in a tensor, which will also store the computation graph and thus increase the memory. If you just want to use alpha for visualizations or debugging, you should detach the tensors from the computation graph using alphas.append(alpha_i.detach()).