@albanD
Here are the values:-
Input shape = torch.Size([128, 442368, 5])
Also output for the code snippet you asked:-
Inside hook:
torch.Size([128, 442368, 1])
(442368, 1, 1)

Also for the .data as you can see here, I am taking the gradients, reshaping it and doing a mask select. I am sorry but I am not sure to which of the mentioned categories would this fall to?