Let’s say I have a tensor of the size

torch.Size([512, 5000, 14, 14])

and I want to sum each 10 entries in second dim, e.g

sum [512, 0:10, :, :] over dim 1

sum [512, 10:20, :, :] over dim 1

…

So the resulting tensor is of size

[512, 500, 14, 14]

Is there any way to do it efficiently without loops?