I would recommend to start with a manual implementation in Python via unfold to get the patches and apply your custom pooling logic to each patch.
Note that the currently returned indices have a variable shape and would thus not be representable in a standard tensor but e.g. a list instead or a nested tensor (which is an experimental feature at the moment).
Once this approach is working properly, you could try to reimplement it as a custom layer in the C++/CUDA backend.