Thanks for the follow-up as I misunderstood your use case.
Based on your description it seems that the returned values would have a variable shape. E.g. one window could have the same max values, while another one a single one.
If that’s the case I think you would have to return a list of these values e.g. by getting the max value via torch.max and checking if duplicates can be found in the current window.
I’m not sure how you would like to further process the result list, as you wouldn’t be able to create a single return tensor (with nested tensors this might be possible).