Using the current master branch, I get the following output for your code.
$ python sample.py 
(True, True)
((256, 8), (256, 8), (256, 8), (256, 4))
('Hx: ', (256, 8))
('kth_excluding: ', (256, 8))

This code crashes on your machine? What version of pytorch are you using?