This line of code calculates the argmax (index of the max. value) in dimension 2 of output, indexes the last dimension (the dim used in argmax will be removed), and converts this value to a Python int value.
I think the better way to see, what exactly is returned would be to execute the operations sequentially and to print out the intermediate return values.