Your code was working before you added ‘dim=X’, the error message was only a warning.
If you want to add dim=something then something must be a number instead of ‘X’.
The number will correspond to the dimension over which the softmax is to be performed.