So the error occurred at the torch.max line during the training. Would you please help me on it? Thank you very much.
X = torch.Tensor(train_input_list)
class RNN(nn.Module):
def __init__(self, num_classes, input_size, hidden_size, num_layers,output_size):
    super(RNN, self).__init__()

    self.num_classes = num_classes
    self.num_layers = num_layers
    self.input_size = input_size
    self.hidden_size = hidden_size
    self.out = torch.nn.Linear(hidden_size, input_size)

    self.rnn = nn.RNN(4, 5,2, batch_first=True)
    self.fc = nn.Linear(hidden_size, output_size)

def forward(self, x):

    batch_size = x.size(0)
    hidden = self.init_hidden(batch_size)
    out, hidden = self.rnn(x, hidden)
    
    out = out.view(-1, self.hidden_size)
    out = self.fc(out)
    
    return out, hidden
def init_hidden(self, batch_size):
    hidden = torch.zeros(self.num_layers, batch_size, self.hidden_size)
    return hidden

rnn = RNN(num_classes, input_size, hidden_size, num_layers,1)
loss_func = nn.CrossEntropyLoss()
for epoch in range(num_epoch):
     Y_pred = rnn(X)
     out, predicted = torch.max(F.softmax(Y_pred,1), 1)```