Here’s a minimal example of pool and unpool:
import torch
from torch import nn

x = torch.rand(1, 3, 540, 960)
pool = nn.MaxPool2d(2, 2, return_indices=True)
unpool = nn.MaxUnpool2d(2, 2)

out, indices = pool(x)
out = unpool(out, indices)