Thanks for the code snippet.
Since it’s not reproducible with the last code, could you try to use:
x= F.max_pool1d(x.transpose(1,2).contiguous(), kernel_size=x.size()[1])

and rerun the script, please?
Also, which PyTorch version are you using?
Make sure to update to the latest stable release, as Variables are deprecated since 0.4.